mlx4: use enum constants instead of const vars for case exprs
Follow up from r324201 to fix compilation with gcc, which complains
about non-ICE case expressions.
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D12675
Differential D12675
mlx4: use enum constants instead of const vars for case exprs rlibby on Oct 14 2017, 8:01 PM. Authored by Tags None Referenced Files
Subscribers None
Details mlx4: use enum constants instead of const vars for case exprs Follow up from r324201 to fix compilation with gcc, which complains Reviewed by: hselasky buildkernel (clang & gcc)
Diff Detail
Event TimelineComment Actions This unbreaks compilation with gcc after r324201. Gcc wants case expressions to be constant expressions. % make CROSS_TOOLCHAIN=amd64-gcc TARGET=amd64 TARGET_ARCH=amd64 buildkernel [...] ===> mlx4en (all) /usr/local/bin/x86_64-unknown-freebsd12.0-gcc -isystem /usr/obj/amd64-gcc/usr/src/freebsd/tmp/usr/include -L/usr/obj/amd64-gcc/usr/src/freebsd/tmp/usr/lib -B/usr/obj/amd64-gcc/usr/src/freebsd/tmp/usr/lib --sysroot=/usr/obj/amd64-gcc/usr/src/freebsd/tmp -B/usr/local/x86_64-freebsd/bin/ -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I/usr/src/freebsd/sys/ofed/include -I/usr/src/freebsd/sys/compat/linuxkpi/common/include -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/amd64-gcc/usr/src/freebsd/sys/GENERIC/opt_global.h -I. -I/usr/src/freebsd/sys -fno-common -g -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/obj/amd64-gcc/usr/src/freebsd/sys/GENERIC -MD -MF.depend.mlx4_en_rx.o -MTmlx4_en_rx.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=address -Wno-error=aggressive-loop-optimizations -Wno-error=array-bounds -Wno-error=attributes -Wno-error=cast-qual -Wno-error=enum-compare -Wno-error=inline -Wno-error=maybe-uninitialized -Wno-error=overflow -Wno-error=sequence-point -Wno-error=unused-but-set-variable -Wno-error=misleading-indentation -Wno-error=nonnull-compare -Wno-error=shift-overflow -Wno-error=tautological-compare -finline-limit=8000 -fms-extensions --param inline-unit-growth=100 --param large-function-growth=1000 -std=iso9899:1999 -c /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c -o mlx4_en_rx.o In file included from /usr/src/freebsd/sys/compat/linuxkpi/common/include/linux/types.h:38:0, from /usr/src/freebsd/sys/dev/mlx4/cq.h:36, from /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:34: /usr/src/freebsd/sys/compat/linuxkpi/common/include/linux/list.h: In function '__list_del': /usr/src/freebsd/sys/compat/linuxkpi/common/include/linux/compiler.h:82:28: warning: to be safe all intermediate pointers in cast from 'struct list_head **' to 'struct list_head * volatile*' must be 'const' qualified [-Wcast-qual] #define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x)) ^ /usr/src/freebsd/sys/compat/linuxkpi/common/include/linux/compiler.h:86:2: note: in expansion of macro 'ACCESS_ONCE' ACCESS_ONCE(x) = (v); \ ^~~~~~~~~~~ /usr/src/freebsd/sys/compat/linuxkpi/common/include/linux/list.h:116:2: note: in expansion of macro 'WRITE_ONCE' WRITE_ONCE(prev->next, next); ^~~~~~~~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c: In function 'mlx4_en_rss_hash': /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:584:2: error: case label does not reduce to an integer constant case status_ipv4_tcp: ^~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:586:2: error: case label does not reduce to an integer constant case status_ipv6_tcp: ^~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:588:2: error: case label does not reduce to an integer constant case status_ipv4_udp: ^~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:591:2: error: case label does not reduce to an integer constant case status_ipv6_udp: ^~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:576:15: warning: variable 'status_ipv6_udp' set but not used [-Wunused-but-set-variable] const __be16 status_ipv6_udp = cpu_to_be16( ^~~~~~~~~~~~~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:573:15: warning: variable 'status_ipv4_udp' set but not used [-Wunused-but-set-variable] const __be16 status_ipv4_udp = cpu_to_be16( ^~~~~~~~~~~~~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:570:15: warning: variable 'status_ipv6_tcp' set but not used [-Wunused-but-set-variable] const __be16 status_ipv6_tcp = cpu_to_be16( ^~~~~~~~~~~~~~~ /usr/src/freebsd/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c:567:15: warning: variable 'status_ipv4_tcp' set but not used [-Wunused-but-set-variable] const __be16 status_ipv4_tcp = cpu_to_be16( ^~~~~~~~~~~~~~~ *** Error code 1 Stop. make[4]: stopped in /usr/src/freebsd/sys/modules/mlx4en *** Error code 1 Stop. make[3]: stopped in /usr/src/freebsd/sys/modules *** Error code 1 Stop. make[2]: stopped in /usr/obj/amd64-gcc/usr/src/freebsd/sys/GENERIC *** Error code 1 Stop. make[1]: stopped in /usr/src/freebsd *** Error code 1 Stop. make: stopped in /usr/src/freebsd
Comment Actions Just give this patch a spin with clang aswell before committing. I'll handle this issue towards Mellanox. Thank you! --HPS Comment Actions Yep, just checked with gcc and clang. Updated summary to intended commit message. Thanks! |