mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Fix a couple of syntactically dangerous macros.
The live versions of the dmemdump macros had a trailing semicolon in the expansion, which would cause them to break if used in the wrong syntactic context (e.g. between if and else with the natural semicolon at the call site). The conditioned-out versions of those and of debug() itself expanded to the empty string in place of the more usual ((void)0). And SECOND_PASS_ONLY in gtkmain.c's command-line handling should have had the standard do ... while(0) wrapper to make it reliably a single statement.
This commit is contained in:
parent
3e881a4248
commit
4ecc3f3c09
10
misc.h
10
misc.h
@ -222,12 +222,12 @@ static inline NORETURN void unreachable_internal(void) { abort(); }
|
||||
void debug_printf(const char *fmt, ...);
|
||||
void debug_memdump(const void *buf, int len, bool L);
|
||||
#define debug(...) (debug_printf(__VA_ARGS__))
|
||||
#define dmemdump(buf,len) debug_memdump (buf, len, false);
|
||||
#define dmemdumpl(buf,len) debug_memdump (buf, len, true);
|
||||
#define dmemdump(buf,len) (debug_memdump(buf, len, false))
|
||||
#define dmemdumpl(buf,len) (debug_memdump(buf, len, true))
|
||||
#else
|
||||
#define debug(...)
|
||||
#define dmemdump(buf,len)
|
||||
#define dmemdumpl(buf,len)
|
||||
#define debug(...) ((void)0)
|
||||
#define dmemdump(buf,len) ((void)0)
|
||||
#define dmemdumpl(buf,len) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifndef lenof
|
||||
|
@ -330,7 +330,7 @@ bool do_cmdline(int argc, char **argv, bool do_everything, Conf *conf)
|
||||
} else \
|
||||
val = *++argv; \
|
||||
}
|
||||
#define SECOND_PASS_ONLY { if (!do_everything) continue; }
|
||||
#define SECOND_PASS_ONLY do { if (!do_everything) continue; } while (0)
|
||||
|
||||
while (--argc > 0) {
|
||||
const char *p = *++argv;
|
||||
|
Loading…
Reference in New Issue
Block a user