]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xdrgen: Generate "if" instead of "switch" for boolean union enumerators
authorChuck Lever <chuck.lever@oracle.com>
Thu, 20 Nov 2025 20:15:52 +0000 (15:15 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 26 Jan 2026 15:10:58 +0000 (10:10 -0500)
commit9654a0388a3abcfa51cb2d010a6624a6f1f46710
tree8260d85e5c72871dead29df325fee4a8ce97dc4a
parente344a031a4928e9f0ae3124f0e45e953a873f3bd
xdrgen: Generate "if" instead of "switch" for boolean union enumerators

Eliminate this warning in code generated by xdrgen:

fs/nfsd/nfs3xdr_gen.c:220:2: warning: switch condition has boolean value [-Wswitch-bool]
  220 |         switch (ptr->attributes_follow) {
      |         ^       ~~~~~~~~~~~~~~~~~~~~~~

No more -Wswitch-bool warnings when compiling with W=1.

The generated code is functionally equivalent but somewhat more
idiomatic.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202511172336.Y75zj4v6-lkp@intel.com/
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
tools/net/sunrpc/xdrgen/generators/union.py
tools/net/sunrpc/xdrgen/templates/C/union/decoder/bool_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/bool_spec.j2 [new file with mode: 0644]