Skip to content

RFC fix -Wempty-body build warnings

Randy Dunlap alsa-devel linux-fsdevel linux-input linux-nfs linux-nvdimm linux-scsi linux-usb lkml nvdimm target-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 29 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9kernel.h: add do_empty() macroinclude/linux/kernel.h+8 -04 replies
2/9fs: fix empty-body warning in posix_acl.cfs/posix_acl.c+1 -13 replies
3/9input: fix empty-body warning in synaptics.cdrivers/input/mouse/synaptics.c+2 -10 replies
4/9sound: fix empty-body warning in vx_core.csound/drivers/vx/vx_core.c+2 -10 replies
5/9usb: fix empty-body warning in sysfs.cdrivers/usb/core/sysfs.c+1 -15 replies
6/9nfsd: fix empty-body warning in nfs4state.cfs/nfsd/nfs4state.c+2 -17 replies
7/9drivers/base: fix empty-body warnings in devcoredump.cdrivers/base/devcoredump.c+3 -29 replies
8/9dax: fix empty-body warnings in bus.cdrivers/dax/bus.c+3 -21 reply
9/9target: fix empty-body warning in target_core_pscsi.cdrivers/target/target_core_pscsi.c+2 -10 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchChuck Lever
1/9
2/9
3/9
4/9
5/9
6/9A-b
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 0/9] fix -Wempty-body build warnings

Hi,

When -Wextra is used, gcc emits many warnings about an empty 'if' or 'else' body, like this:

../fs/posix_acl.c: In function ‘get_acl’:
../fs/posix_acl.c:127:22: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]

   /* fall through */ ;
                      ^

To quieten these warnings, add a new macro "do_empty()". I originally wanted to use do_nothing(), but that's already in use.

It would sorta be nice if "fallthrough" could be coerced for this instead of using something like do_empty().

Or should we just use "{}" in place of ";"?
This causes some odd coding style issue IMO. E.g., see this change:

original:
if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED)

		/* fall through */ ;

with new macro:
if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED)

		do_empty(); /* fall through */

using {}:
if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED)

		{} /* fall through */
or
		{ /* fall through */ }
or even
 	if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED) {
		/* fall through */ }
or
 	if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED) {
		} /* fall through */
 drivers/base/devcoredump.c         |    5 +++--
 drivers/dax/bus.c                  |    5 +++--
 drivers/input/mouse/synaptics.c    |    3 ++-
 drivers/target/target_core_pscsi.c |    3 ++-
 drivers/usb/core/sysfs.c           |    2 +-
 fs/nfsd/nfs4state.c                |    3 ++-
 fs/posix_acl.c                     |    2 +-
 include/linux/kernel.h             |    8 ++++++++
 sound/drivers/vx/vx_core.c         |    3 ++-
 9 files changed, 24 insertions(+), 10 deletions(-)