printf: fix errname.c list
PATCH RESEND v4 1/1 printf: fix errname.c list
From: Arnd Bergmann <[email protected]>
On most architectures, gcc -Wextra warns about the list of error numbers containing both EDEADLK and EDEADLOCK:
lib/errname.c:15:67: warning: initialized field overwritten [-Woverride-init]
15 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~lib/errname.c:172:2: note: in expansion of macro 'E'
172 | E(EDEADLK), /* EDEADLOCK */
| ^On parisc, a similar error happens with -ECANCELLED, which is an alias for ECANCELED.
Make the EDEADLK printing conditional on the number being distinct from EDEADLOCK, and remove the -ECANCELLED bit completely as it can never be hit.
To ensure these are correct, add static_assert lines that verify all the remaining aliases are in fact identical to the canonical name.
---
I sent this a few times, but it never made it in so far. The warning still shows up when enabling extra warnings, and this is an actual bug.
--- lib/errname.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
lib/errname.c +14 -8
@@ -21,6 +21,7 @@ static const char *names_0[] = {E (EADDRNOTAVAIL ),E (EADV ),E (EAFNOSUPPORT ), +E (EAGAIN ),/* EWOULDBLOCK */ E (EALREADY ),E (EBADE ), E(EBADF),
@@ -31,15 +32,17 @@ static const char *names_0[] = {E (EBADSLT ),E (EBFONT ),E (EBUSY ), -#ifdef ECANCELLED -E (ECANCELLED ), -#endif +E (ECANCELED ),/* ECANCELLED */ E (ECHILD ),E (ECHRNG ),E (ECOMM ),E (ECONNABORTED ), +E (ECONNREFUSED ),/* EREFUSED */ E (ECONNRESET ), +E (EDEADLK ),/* EDEADLOCK */ +#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */E (EDEADLOCK ), +#endifE (EDESTADDRREQ ),E (EDOM ), E(EDOTDOT),
@@ -166,14 +169,17 @@ static const char *names_0[] = {E (EUSERS ),E (EXDEV ), E(EXFULL), - -E (ECANCELED ),/* ECANCELLED */ -E (EAGAIN ),/* EWOULDBLOCK */ -E (ECONNREFUSED ),/* EREFUSED */ - E(EDEADLK), /* EDEADLOCK */ };#undef E +#ifdef EREFUSED /* parisc */ +static_assert (EREFUSED ==ECONNREFUSED ); +#endif +#ifdef ECANCELLED /* parisc */ +static_assert (ECANCELLED ==ECANCELED ); +#endif +static_assert (EAGAIN ==EWOULDBLOCK );/* everywhere */ +#define E (err) [err - 512 + BUILD_BUG_ON_ZERO(err < 512 || err > 550)] = "-" #errstatic const char *names_512[] = {E (ERESTARTSYS ),
Signature · 1 line
2.39.0
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
On most architectures, gcc -Wextra warns about the list of error numbers containing both EDEADLK and EDEADLOCK:
[...]
Quoted 7 lines
To ensure these are correct, add
static_assertlines that verify all the remaining aliases are in fact identical to the canonical name.Fixes 57f5677e535b ("printf: add support for printing symbolic error names")Cc Petr Mladek <[email protected]>Suggested-by Rasmus Villemoes <[email protected]>
You may also add Acked-by: me.
Quoted 8 lines
Acked-by Uwe Kleine-König <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
I sent this a few times, but it never made it in so far. The warning still shows up when enabling extra warnings, and this is an actual bug.
Petr, please pick this up.
Rasmus
Quoted 13 lines · Arnd Bergmann
On most architectures, gcc -Wextra warns about the list of error numbers containing both EDEADLK and EDEADLOCK:
lib/errname.c:15:67: warning: initialized field overwritten [-Woverride-init]
15 | #define E(err) [err +BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~lib/errname.c:172:2: note: in expansion of macro 'E'172 | E(EDEADLK), /* EDEADLOCK */ | ^On parisc, a similar error happens with
-ECANCELLED, which is an alias for ECANCELED.
Quoted 8 lines
Make the EDEADLK printing conditional on the number being distinct from EDEADLOCK, and remove the
-ECANCELLEDbit completely as it can never be hit.To ensure these are correct, add
static_assertlines that verify all the remaining aliases are in fact identical to the canonical name.
Quoted 23 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
On most architectures, gcc -Wextra warns about the list of error numbers containing both EDEADLK and EDEADLOCK:
lib/errname.c:15:67: warning: initialized field overwritten [-Woverride-init]
15 | #define E(err) [err +BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~lib/errname.c:172:2: note: in expansion of macro 'E'172 | E(EDEADLK), /* EDEADLOCK */ | ^On parisc, a similar error happens with
-ECANCELLED, which is an alias for ECANCELED.Make the EDEADLK printing conditional on the number being distinct from EDEADLOCK, and remove the
-ECANCELLEDbit completely as it can never be hit.To ensure these are correct, add
static_assertlines that verify all the remaining aliases are in fact identical to the canonical name.
Quoted 8 lines
Fixes 57f5677e535b ("printf: add support for printing symbolic error names")Cc Petr Mladek <[email protected]>Suggested-by Rasmus Villemoes <[email protected]>Acked-by Uwe Kleine-König <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
I have just pushed the patch into printk/linux.git, branch for-6.3.
Quoted 2 lines
I sent this a few times, but it never made it in so far. The warning still shows up when enabling extra warnings, and this is an actual bug.
I am sorry for the delay, v3 somehow fallen under cracks. Anyway, v4 seems to be the only resend that I got. v3 was needed because of a problem reported in v2.
Best Regards,
Petr