From 455bd824457b3e6cc3998817aac4e500b027cc50 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 24 Feb 2018 12:33:06 -0500 Subject: [PATCH] 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. --- src/internal/stdio_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.25.1