From a455452d7ee98d160620925bb8a0e3d0f4dfd7ec Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Tue, 1 Oct 2019 12:14:41 -0600 Subject: [PATCH] LINUX 5.3: Add comments for fallthrough switch cases With commit 6e0f1c3b45102e7644d25cf34395ca980414317f (LINUX: Honor --enable-checking for libafs) building libafs against a linux 5.3 kernel compiles with errors due to fall through in case statements when --enable-checking / --enable-warning is used. e.g. src/opr/jhash.h:82:17: error: this statement may fall through [-Werror=implicit-fallthrough=] case 3 : c+=k[2]; ~^~~~~~ The GCC compiler will disable the implicit-fallthrough check for case statements that contain a "special" comment ( /* fall through */ ). Add the 'fall through' comment to indicate where fall throughs are acceptable. This commit only adds comments and does not alter any executable code. The -Wimplicit-fallthrough flag was enabled globally in the linux kernel build in 5.3-rc2 (commit: a035d552a93bb9ef6048733bb9f2a0dc857ff869 Makefile: Globally enable fall-through warning) Change-Id: Ie6ca425e04b53a22d07b415cb8afd172af7e8081 Reviewed-on: https://gerrit.openafs.org/13881 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- src/afs/LINUX/osi_vnodeops.c | 1 + src/opr/jhash.h | 3 +++ src/rx/xdr.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index dc39822e43..d6fa3b6242 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -2580,6 +2580,7 @@ afs_linux_can_bypass(struct inode *ip) { case LARGE_FILES_BYPASS_CACHE: if (i_size_read(ip) > cache_bypass_threshold) return 1; + /* fall through */ default: return 0; } diff --git a/src/opr/jhash.h b/src/opr/jhash.h index 9c82f9c98a..4568f567c1 100644 --- a/src/opr/jhash.h +++ b/src/opr/jhash.h @@ -80,9 +80,12 @@ opr_jhash(const afs_uint32 *k, size_t length, afs_uint32 initval) /* All the case statements fall through */ switch(length) { case 3 : c+=k[2]; + /* fall through */ case 2 : b+=k[1]; + /* fall through */ case 1 : a+=k[0]; opr_jhash_final(a, b, c); + /* fall through */ case 0: /* case 0: nothing left to add */ break; } diff --git a/src/rx/xdr.c b/src/rx/xdr.c index f370723398..b1efad33e8 100644 --- a/src/rx/xdr.c +++ b/src/rx/xdr.c @@ -424,7 +424,7 @@ xdr_bytes(XDR * xdrs, char **cpp, u_int * sizep, if (sp == NULL) { return (FALSE); } - /* fall into ... */ + /* fall through */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, nodesize)); @@ -547,7 +547,7 @@ xdr_string(XDR * xdrs, char **cpp, u_int maxsize) return (FALSE); } sp[size] = 0; - /* fall into ... */ + /* fall through */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, size));