Browse Source

use idiomatic safe form for FUNLOCK macro

previously this macro used an odd if/else form instead of the more
idiomatic do/while(0), making it unsafe against omission of trailing
semicolon. the omission would make the following statement conditional
instead of producing an error.
master
Rich Felker 8 years ago
parent
commit
455bd82445
  1. 2
      src/internal/stdio_impl.h

2
src/internal/stdio_impl.h

@ -9,7 +9,7 @@
#define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0)
#define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0)
#define FUNLOCK(f) if (__need_unlock) __unlockfile((f)); else
#define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0)
#define F_PERM 1
#define F_NORD 4

Loading…
Cancel
Save