Skip to content

Commit 0c2baf6

Browse files
arndbpmladek
authored andcommitted
printf: fix errname.c list
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. Fixes: 57f5677 ("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]> Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Acked-by: Rasmus Villemoes <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 55bf243 commit 0c2baf6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/errname.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static const char *names_0[] = {
2121
E(EADDRNOTAVAIL),
2222
E(EADV),
2323
E(EAFNOSUPPORT),
24+
E(EAGAIN), /* EWOULDBLOCK */
2425
E(EALREADY),
2526
E(EBADE),
2627
E(EBADF),
@@ -31,15 +32,17 @@ static const char *names_0[] = {
3132
E(EBADSLT),
3233
E(EBFONT),
3334
E(EBUSY),
34-
#ifdef ECANCELLED
35-
E(ECANCELLED),
36-
#endif
35+
E(ECANCELED), /* ECANCELLED */
3736
E(ECHILD),
3837
E(ECHRNG),
3938
E(ECOMM),
4039
E(ECONNABORTED),
40+
E(ECONNREFUSED), /* EREFUSED */
4141
E(ECONNRESET),
42+
E(EDEADLK), /* EDEADLOCK */
43+
#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */
4244
E(EDEADLOCK),
45+
#endif
4346
E(EDESTADDRREQ),
4447
E(EDOM),
4548
E(EDOTDOT),
@@ -166,14 +169,17 @@ static const char *names_0[] = {
166169
E(EUSERS),
167170
E(EXDEV),
168171
E(EXFULL),
169-
170-
E(ECANCELED), /* ECANCELLED */
171-
E(EAGAIN), /* EWOULDBLOCK */
172-
E(ECONNREFUSED), /* EREFUSED */
173-
E(EDEADLK), /* EDEADLOCK */
174172
};
175173
#undef E
176174

175+
#ifdef EREFUSED /* parisc */
176+
static_assert(EREFUSED == ECONNREFUSED);
177+
#endif
178+
#ifdef ECANCELLED /* parisc */
179+
static_assert(ECANCELLED == ECANCELED);
180+
#endif
181+
static_assert(EAGAIN == EWOULDBLOCK); /* everywhere */
182+
177183
#define E(err) [err - 512 + BUILD_BUG_ON_ZERO(err < 512 || err > 550)] = "-" #err
178184
static const char *names_512[] = {
179185
E(ERESTARTSYS),

0 commit comments

Comments
 (0)