[PATCH v2 2/2] powerpc/math-emu: Remove -w build flag and fix warnings

Nathan Chancellor nathan at kernel.org
Sat Sep 3 01:37:23 AEST 2022


Hi Christophe,

On Fri, Sep 02, 2022 at 12:08:55PM +0200, Christophe Leroy wrote:
> As reported by Nathan, the module_init() macro was not taken into
> account because the header was missing. That means spe_mathemu_init()
> was never called.
> 
> This should have been detected by gcc at build time, but due to
> '-w' flag it went undetected.
> 
> Removing that flag leads to many warnings hence errors.
> 
> Fix those warnings then remove the -w flag.
> 
> Reported-by: Nathan Chancellor <nathan at kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>

Thanks for figuring out what was going on here! I took this patch for a
spin with clang and it has a few more errors around
-Wimplicit-fallthrough:

    arch/powerpc/math-emu/fctiw.c:18:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
            FP_TO_INT_D(r, B, 32, 1);
            ^
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/fctiw.c:18:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    2 errors generated.
    arch/powerpc/math-emu/fctiwz.c:23:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
            FP_TO_INT_D(r, B, 32, 1);
            ^
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/fctiwz.c:23:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    2 errors generated.
    make[3]: *** [scripts/Makefile.build:249: arch/powerpc/math-emu/fctiw.o] Error 1
    make[3]: *** [scripts/Makefile.build:249: arch/powerpc/math-emu/fctiwz.o] Error 1
    arch/powerpc/math-emu/math_efp.c:282:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[1], SB, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:305:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[1], SB, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:316:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_S(vc.wp[1], SB, 32,
                                    ^
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/math_efp.c:316:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:413:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_D(vc.wp[1], DB, 32,
                                    ^
    ./include/math-emu/double.h:121:40: note: expanded from macro 'FP_TO_INT_ROUND_D'
    #define FP_TO_INT_ROUND_D(r,X,rsz,rsg)  _FP_TO_INT_ROUND(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:436:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_D(vc.dp[0], DB, 64,
                                    ^
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/math_efp.c:436:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:447:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_D(vc.wp[1], DB, 32,
                                    ^
    ./include/math-emu/double.h:121:40: note: expanded from macro 'FP_TO_INT_ROUND_D'
    #define FP_TO_INT_ROUND_D(r,X,rsz,rsg)  _FP_TO_INT_ROUND(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:458:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_D(vc.wp[1], DB, 32,
                                    ^
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/math_efp.c:458:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/double.h:120:34: note: expanded from macro 'FP_TO_INT_D'
    #define FP_TO_INT_D(r,X,rsz,rsg)        _FP_TO_INT(D,2,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:573:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[0], SB0, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:581:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[1], SB1, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:592:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[0], SB0, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:599:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_ROUND_S(vc.wp[1], SB1, 32,
                                    ^
    ./include/math-emu/single.h:110:40: note: expanded from macro 'FP_TO_INT_ROUND_S'
    #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:770:4: note: expanded from macro '_FP_TO_INT_ROUND'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:610:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_S(vc.wp[0], SB0, 32,
                                    ^
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/math_efp.c:610:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    arch/powerpc/math-emu/math_efp.c:617:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                                    FP_TO_INT_S(vc.wp[1], SB1, 32,
                                    ^
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:665:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_ZERO:                                                     \
              ^
    arch/powerpc/math-emu/math_efp.c:617:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    ./include/math-emu/single.h:109:34: note: expanded from macro 'FP_TO_INT_S'
    #define FP_TO_INT_S(r,X,rsz,rsg)        _FP_TO_INT(S,1,r,X,rsz,rsg)
                                            ^
    ./include/math-emu/op-common.h:671:4: note: expanded from macro '_FP_TO_INT'
              case FP_CLS_NAN:                                                      \
              ^
    18 errors generated.

The following diff resolves it and does not introduce any new issues
with GCC. Would you mind squashing it in for a v2? With that:

Reviewed-by: Nathan Chancellor <nathan at kernel.org>

Cheers,
Nathan

diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h
index 4b57bbba588a..ae73a30bf1a0 100644
--- a/include/math-emu/op-common.h
+++ b/include/math-emu/op-common.h
@@ -662,12 +662,14 @@ do {									\
 	if (X##_e < 0)								\
 	  {									\
 	    FP_SET_EXCEPTION(FP_EX_INEXACT);					\
+	    fallthrough;							\
 	  case FP_CLS_ZERO:							\
 	    r = 0;								\
 	  }									\
 	else if (X##_e >= rsize - (rsigned > 0 || X##_s)			\
 		 || (!rsigned && X##_s))					\
 	  {	/* overflow */							\
+	  fallthrough;								\
 	  case FP_CLS_NAN:                                                      \
 	  case FP_CLS_INF:							\
 	    if (rsigned == 2)							\
@@ -767,6 +769,7 @@ do {									\
 	if (X##_e >= rsize - (rsigned > 0 || X##_s)				\
 	    || (!rsigned && X##_s))						\
 	  {	/* overflow */							\
+	  fallthrough;								\
 	  case FP_CLS_NAN:                                                      \
 	  case FP_CLS_INF:							\
 	    if (!rsigned)							\


More information about the Linuxppc-dev mailing list