From: Rich Felker Date: Sat, 24 Feb 2018 17:33:06 +0000 (-0500) Subject: use idiomatic safe form for FUNLOCK macro X-Git-Tag: v1.1.20~145 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=455bd824457b3e6cc3998817aac4e500b027cc50;p=oweals%2Fmusl.git 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. --- diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index 7cdf729d..1127a492 100644 --- a/src/internal/stdio_impl.h +++ b/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