Commit graph

106 commits

Author SHA1 Message Date
Kp 0f9db40e36 Simplify reporting fatal errors 2017-08-11 23:43:52 +00:00
Kp 9205296380 Print fatal errors to console before calling hook function
On Windows, the hook function blocks until the user dismisses the
message box.  Print the message before opening the message box so that
it is available on the console, if one exists.
2017-08-02 02:49:12 +00:00
Kp 8ccf0e5301 Add PHYSFS_read wrapper support
- Add wrappers for PHYSFS_read and its convenience functions.  Poison
  the memory before calling PHYSFS, so that any uninitialized bytes
  (likely caused by a short read) are reported if the caller tries to
  access the value anyway.
- Add SConstruct options to enable wrapping, so that users do not need
  to enumerate the wrapped functions manually.
- Fix link failure when using LTO+wrappers.
2017-07-26 03:15:58 +00:00
Kp a815541ef5 Fix check_header_includes=1 poison.h 2017-02-19 19:33:36 +00:00
Kp 6ac840c52c Fix pch=1 build
PCH mode causes the Valgrind-wrapper header to be included in places
it is not meant to be used, which leads to spurious compiler errors.

PCH mode causes the Valgrind-wrapper __real_* stub functions to see
the physfsx.h PHYSFS macros, which also causes errors.

Fortunately, both cases can be easily fixed.

Add preprocessor guards to the Valgrind-wrapper header to cause it to
compile out when the PCH phase runs.  It has no include guard, so it
will be rescanned with the proper macros when the two consuming files
are built normally.

Modify the Valgrind-wrapper __real_* stub functions to use
the standard macro avoidance trick so that they do not call the
physfsx.h PHYSFS macros.
2017-01-31 04:25:06 +00:00
Kp 2c4af523dd Use ugly preprocessor hook hack to fix Clang build failure
Clang rejects a declared (but never defined and never used) `static`
function.  Change the declaration to be the value of a macro that will
be expanded only when the function is both defined and used.

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/295>
Fixes: 55822d0b4d ("Add wrappers for more precise Valgrind physfs diagnostics")
2017-01-07 19:09:04 +00:00
Kp 55822d0b4d Add wrappers for more precise Valgrind physfs diagnostics 2017-01-01 23:19:21 +00:00
Kp 51a897e6a7 Use range_for for hmp reset_tracks 2016-10-29 23:16:18 +00:00
Kp aabd01c9ad Use range_for in hmp_open 2016-10-29 23:16:17 +00:00
Kp 6a8cc912e1 Switch hmp.cpp to use C++ casts 2016-09-04 19:10:43 +00:00
Kp 705bbff53a Remove bogus cast in Win32 MIDI get_event
Casting `&unsigned` to `(unsigned long *)` is wrong.  It happened to
work because these types are the same size on Windows and this code is
only used on Windows.  Remove the bogus cast and fix the function
prototype.
2016-09-04 19:10:43 +00:00
Kp 4293227a54 Move strutil qsort comparator casts into function 2016-09-04 19:10:42 +00:00
Kp c5d154b6e0 Switch ignorecase.cpp to C++ static_cast 2016-09-04 00:02:52 +00:00
Kp 0c43357d85 Move HMP->MIDI magic numbers into magic_header[]
This removes some useless casts from the serializer.
2016-08-19 03:41:40 +00:00
Kp 59750d3c29 Rewrite declarations of ubyte * to standard uint8_t * 2016-07-14 01:59:02 +00:00
Kp 0bed5d4727 Rewrite simple HMIDIOUT casts from C style to reinterpret_cast<>
s/(\(HMIDIOUT\))(/reinterpret_cast<\1>(/g
2016-07-08 04:14:59 +00:00
Kp 95d3a9d31c Rewrite simple DWORD casts from C style to static_cast<>
s/(\(DWORD\))(/static_cast<\1>(/g
2016-07-08 04:14:59 +00:00
Kp c8e8c568ff Add parentheses around target of simple HMIDIOUT casts
s/(\s*HMIDIOUT\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(HMIDIOUT)(\1\2\3)\4/g
2016-07-08 04:14:58 +00:00
Kp 2bc994e673 Add parentheses around target of simple DWORD casts
s/(\s*DWORD\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(DWORD)(\1\2\3)\4/g
2016-07-08 04:14:58 +00:00
Kp 59fb7fa4cb Convert hmp casts from C style to reinterpret_cast<> 2016-07-07 03:08:13 +00:00
Kp b0a2205a4e Convert various pointer casts to reinterpret_cast 2016-07-06 01:54:24 +00:00
Kp b35a893d9a Rewrite simple pointer casts from C style to reinterpret_cast<>
s/(\s*\(\w\+\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:15 +00:00
Kp 19f31eb420 Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets int8_t and uint8_t.

s/(\s*\(u\?int8_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:14 +00:00
Kp a7ceee3c03 Add parentheses around target of simple unsigned char casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

s/(\s*unsigned\s\+char\s*\(\*\+\)\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(uint8_t \1)(\2\3\4)\5/g
2016-07-03 00:54:14 +00:00
Kp c7953a3df1 Fix Win32 use of static_cast where reinterpret_cast is needed 2016-07-02 02:04:11 +00:00
Kp 231223895d Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\*\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp b282bea173 Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp 7fdce88558 Add parentheses around target of simple casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets.  It also works only on commonly used standard types.

	(int) a->b;	// changed
	(int) a[b];	// not changed

s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
2016-06-05 01:04:25 +00:00
Kp 73b7905125 Fix -Wshadow warning in get_event (Windows only)
Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/200>
2016-06-01 01:52:45 +00:00
Kp 27cef20eb3 Move namespace dsx handling to dsx-ns.h 2016-03-19 19:08:10 +00:00
Kp 1a4290002e Revert partial_const_range for HMP get_event
Fixes: b57f08c798 ("Use partial_const_range")
2016-02-17 03:34:30 +00:00
Kp b57f08c798 Use partial_const_range 2016-02-12 04:02:28 +00:00
Kp 86709f547b Fix capitalization of PHYSFS_File
Per comment in physfs.h, the spelling PHYSFS_file is deprecated.
Replace all instances with PHYSFS_File.
2016-01-09 16:38:14 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp 5b9e50a815 Use inline namespace dcx for common/misc 2015-12-05 22:57:24 +00:00
Kp dad504cfef Fix some -Wshadow warnings 2015-11-26 02:56:54 +00:00
Kp 3ceefb4189 Pass filename to Error 2015-10-11 22:21:00 +00:00
Kp 1d99084026 Use UserError when main hog is missing
Error traps to the debugger and then aborts, which is not appropriate
for a user setup error.
2015-10-09 02:46:11 +00:00
Kp a58e8f87a0 Move similar/misc/hash.cpp -> common/misc/hash.cpp 2015-07-18 21:01:56 +00:00
Kp 968cdbecf4 Add non-aborting UserError for user-caused fatal errors 2015-06-16 03:15:40 +00:00
Kp ce72014e2e Always parse WORDS_BIGENDIAN and !WORDS_BIGENDIAN 2015-06-13 22:42:21 +00:00
Kp 64ee9e0047 Improve memdebug d_strdup trace 2015-06-11 03:06:58 +00:00
Kp fc4b686d9d Store PHYSFS_list element count in list when needed 2015-05-09 17:38:57 +00:00
Kp 6792c1bc4b Enable -Wunused-parameter 2015-04-26 20:15:56 +00:00
Kp c3925353fd Use null_sentinel_iterator for PHYSFS_list_t 2015-04-26 20:15:51 +00:00
Kp 84c638ed64 Move PHYSFS_list_t to separate header 2015-04-19 04:18:49 +00:00
Kp 150e2d2686 Convert local arrays to array<> 2015-04-19 04:18:49 +00:00
Kp 3e520afc89 Reduce size of hmp_open buffer 2015-04-19 04:18:49 +00:00
Kp 66a70fd373 Prepare for global arrays to be array<> 2015-04-02 02:36:52 +00:00
Kp 08f6ad4bc7 Enable nested INI files 2015-03-22 18:49:21 +00:00