From b66c51a6f83302b2776cddf4bea101b07d1c209c Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Thu, 9 Mar 2017 10:25:40 +0100 Subject: [PATCH] Fix handling of SG_LOG()'s second argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The popup/no popup logic in SG_LOG() could be wrong before this commit, because of missing parentheses around uses of the second macro argument. For instance, this: SG_LOG(SG_NAVCACHE, t == 0 ? SG_WARN : SG_ALERT, "Message"); could cause a popup window to be displayed even though neither SG_WARN nor SG_ALERT should do that in the current state of the logging system. Thanks to Szymon AcedaƄski for finding this. --- simgear/debug/logstream.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simgear/debug/logstream.hxx b/simgear/debug/logstream.hxx index e77ea330..0fa5942a 100644 --- a/simgear/debug/logstream.hxx +++ b/simgear/debug/logstream.hxx @@ -168,10 +168,10 @@ logstream& sglog(); do { if(sglog().would_log(C,P)) { \ std::ostringstream os; os << M; \ sglog().log(C, P, __FILE__, __LINE__, os.str()); \ - if (P == SG_POPUP) sglog().popup(os.str()); \ + if ((P) == SG_POPUP) sglog().popup(os.str()); \ } } while(0) #ifdef FG_NDEBUG -# define SG_LOG(C,P,M) do { if(P == SG_POPUP) SG_LOGX(C,P,M) } while(0) +# define SG_LOG(C,P,M) do { if((P) == SG_POPUP) SG_LOGX(C,P,M) } while(0) #else # define SG_LOG(C,P,M) SG_LOGX(C,P,M) #endif