Lists: | pgsql-hackers |
---|
From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | [PATCH] warning: suggest braces around empty body in an 'else' statement |
Date: | 2013-11-07 23:00:39 |
Message-ID: | 20131107230039.GK28314@alap2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
Compiling postgres I currently get the following warning when compiling
without LOCK_DEBUG:
/home/andres/src/postgresql/src/backend/storage/lmgr/lock.c:944:52:
warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
PROCLOCK_PRINT("LockAcquire: NOWAIT", proclock);
It'd be easy to just disable the warning with -Wno-empty-body, but I actually like
the warning.
It's easy to fix by defining PROCLOCK_PRINT to (void)0 instead of
defining it empty when LOCK_DEBUG is enabled.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachment | Content-Type | Size |
---|---|---|
fix-suggest-braces-empty-body-warning.diff | text/x-diff | 518 bytes |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] warning: suggest braces around empty body in an 'else' statement |
Date: | 2013-11-08 00:09:32 |
Message-ID: | 7768.1383869372@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> Compiling postgres I currently get the following warning when compiling
> without LOCK_DEBUG:
> /home/andres/src/postgresql/src/backend/storage/lmgr/lock.c:944:52:
> warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
> PROCLOCK_PRINT("LockAcquire: NOWAIT", proclock);
> It'd be easy to just disable the warning with -Wno-empty-body, but I actually like
> the warning.
> It's easy to fix by defining PROCLOCK_PRINT to (void)0 instead of
> defining it empty when LOCK_DEBUG is enabled.
Seems reasonable, and probably a good policy even without compiler
warnings pushing us to do it --- things that look like functions
should expand to expressions, IMO, not empty.
Committed with some extra parentheses just for luck.
regards, tom lane