drbd: avoid clang warning about pointless switch statement
PATCH 1/1 drbd: avoid clang warning about pointless switch statement
The drbd code causes warnings that we cannot easily disable when building with clang:
In file included from drivers/block/drbd/drbd_debugfs.c:10:
In file included from drivers/block/drbd/drbd_int.h:48:
In file included from include/linux/drbd_genl_api.h:53:
In file included from include/linux/genl_magic_struct.h:237:include/linux/drbd_genl.h:300:1: warning: no case matching constant switch condition '0'
There is nothing wrong with the code, and adding 'default:' labels in the right place is enough to let clang shut up about the warning.
--- include/linux/genl_magic_struct.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/genl_magic_struct.h +3 -0
@@ -190,6 +190,7 @@ static inline void ct_assert_unique_operations(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +default : ; } }
@@ -208,6 +209,7 @@ static inline void ct_assert_unique_top_level_attributes(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +default : ; } }
@@ -218,6 +220,7 @@ static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ { \switch (0 ) { \s_fields \ + default: \ ; \ } \ }
Signature · 1 line
2.9.0
Lars Ellenberg
maintainerAck.
Ok, not exactly "pintless", it's a valid compile time assert for uniq ids, basically a BUILD_BUG_ON(duplicate-ids). But adding a default clause there does not hurt.
Thanks,
Lars
Quoted 47 lines · Arnd Bergmann
The drbd code causes warnings that we cannot easily disable when building with clang:
In file included from
drivers/block/drbd/drbd_debugfs.c:10:
In file included fromdrivers/block/drbd/drbd_int.h:48:
In file included frominclude/linux/drbd_genl_api.h:53:
In file included frominclude/linux/genl_magic_struct.h:237:include/linux/drbd_genl.h:300:1: warning: no case matching constant switch condition '0'There is nothing wrong with the code, and adding 'default:' labels in the right place is enough to let clang shut up about the warning.
Fixes ec2c35ac1ea2 ("drbd: prepare the transition from connector to genetlink")Signed-off-by Arnd Bergmann <[email protected]>--- include/linux/genl_magic_struct.h | 3 +++ 1 file changed, 3 insertions(+)include/linux/genl_magic_struct.h +3
-0@@ -190,6 +190,7 @@ static inline void ct_assert_unique_operations(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +default : ; } }@@ -208,6 +209,7 @@ static inline void ct_assert_unique_top_level_attributes(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +default : ; } }@@ -218,6 +220,7 @@ static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ { \switch (0 ) { \s_fields \ + default: \ ; \ } \ }Signature · 1 line
2.9.0