* [PATCH] [v2] printf: fix errname.c list
@ 2021-05-14 21:34 Arnd Bergmann
2021-05-17 6:26 ` Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-05-14 21:34 UTC (permalink / raw)
To: Petr Mladek, Rasmus Villemoes, Uwe Kleine-König, Andy Shevchenko
Cc: Arnd Bergmann, Andrew Morton, Andy Shevchenko, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
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: 57f5677e535b ("printf: add support for printing symbolic error names")
Cc: Petr Mladek <pmladek@suse.com>
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
lib/errname.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lib/errname.c b/lib/errname.c
index 05cbf731545f..6c5c0aa4de75 100644
--- a/lib/errname.c
+++ b/lib/errname.c
@@ -21,6 +21,7 @@ static const char *names_0[] = {
E(EADDRNOTAVAIL),
E(EADV),
E(EAFNOSUPPORT),
+ E(EAGAIN), /* EWOULDBLOCK */
E(EALREADY),
E(EBADE),
E(EBADF),
@@ -38,8 +39,12 @@ static const char *names_0[] = {
E(ECHRNG),
E(ECOMM),
E(ECONNABORTED),
+ E(ECONNREFUSED), /* EREFUSED */
E(ECONNRESET),
+ E(EDEADLK), /* EDEADLOCK */
+#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */
E(EDEADLOCK),
+#endif
E(EDESTADDRREQ),
E(EDOM),
E(EDOTDOT),
@@ -166,14 +171,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)] = "-" #err
static const char *names_512[] = {
E(ERESTARTSYS),
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] printf: fix errname.c list
2021-05-14 21:34 [PATCH] [v2] printf: fix errname.c list Arnd Bergmann
@ 2021-05-17 6:26 ` Andy Shevchenko
2021-05-17 7:38 ` Uwe Kleine-König
2021-05-17 8:07 ` Rasmus Villemoes
2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-05-17 6:26 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Petr Mladek, Rasmus Villemoes, Uwe Kleine-König,
Arnd Bergmann, Andrew Morton, linux-kernel
On Fri, May 14, 2021 at 11:34:50PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
Looks good to me, thanks for fixing this.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Fixes: 57f5677e535b ("printf: add support for printing symbolic error names")
> Cc: Petr Mladek <pmladek@suse.com>
> Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> lib/errname.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/lib/errname.c b/lib/errname.c
> index 05cbf731545f..6c5c0aa4de75 100644
> --- a/lib/errname.c
> +++ b/lib/errname.c
> @@ -21,6 +21,7 @@ static const char *names_0[] = {
> E(EADDRNOTAVAIL),
> E(EADV),
> E(EAFNOSUPPORT),
> + E(EAGAIN), /* EWOULDBLOCK */
> E(EALREADY),
> E(EBADE),
> E(EBADF),
> @@ -38,8 +39,12 @@ static const char *names_0[] = {
> E(ECHRNG),
> E(ECOMM),
> E(ECONNABORTED),
> + E(ECONNREFUSED), /* EREFUSED */
> E(ECONNRESET),
> + E(EDEADLK), /* EDEADLOCK */
> +#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */
> E(EDEADLOCK),
> +#endif
> E(EDESTADDRREQ),
> E(EDOM),
> E(EDOTDOT),
> @@ -166,14 +171,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)] = "-" #err
> static const char *names_512[] = {
> E(ERESTARTSYS),
> --
> 2.29.2
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] printf: fix errname.c list
2021-05-14 21:34 [PATCH] [v2] printf: fix errname.c list Arnd Bergmann
2021-05-17 6:26 ` Andy Shevchenko
@ 2021-05-17 7:38 ` Uwe Kleine-König
2021-05-17 8:07 ` Rasmus Villemoes
2 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2021-05-17 7:38 UTC (permalink / raw)
To: Arnd Bergmann, Petr Mladek, Rasmus Villemoes, Andy Shevchenko
Cc: Arnd Bergmann, Andrew Morton, Andy Shevchenko, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 1301 bytes --]
Hi Arnd,
On 5/14/21 11:34 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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: 57f5677e535b ("printf: add support for printing symbolic error names")
> Cc: Petr Mladek <pmladek@suse.com>
> Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
LGTM
Acked-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Thanks
Uwe
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] printf: fix errname.c list
2021-05-14 21:34 [PATCH] [v2] printf: fix errname.c list Arnd Bergmann
2021-05-17 6:26 ` Andy Shevchenko
2021-05-17 7:38 ` Uwe Kleine-König
@ 2021-05-17 8:07 ` Rasmus Villemoes
2021-05-17 8:46 ` Arnd Bergmann
2 siblings, 1 reply; 5+ messages in thread
From: Rasmus Villemoes @ 2021-05-17 8:07 UTC (permalink / raw)
To: Arnd Bergmann, Petr Mladek, Uwe Kleine-König, Andy Shevchenko
Cc: Arnd Bergmann, Andrew Morton, Andy Shevchenko, linux-kernel
On 14/05/2021 23.34, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> from EDEADLOCK, and remove the -ECANCELLED bit completely as it
>
> diff --git a/lib/errname.c b/lib/errname.c
> index 05cbf731545f..6c5c0aa4de75 100644
> --- a/lib/errname.c
> +++ b/lib/errname.c
> @@ -21,6 +21,7 @@ static const char *names_0[] = {
> E(EADDRNOTAVAIL),
> E(EADV),
> E(EAFNOSUPPORT),
> + E(EAGAIN), /* EWOULDBLOCK */
> E(EALREADY),
> E(EBADE),
> E(EBADF),
> @@ -38,8 +39,12 @@ static const char *names_0[] = {
somewhere between EBADF and ECHRNG I'd expect a hunk dealing with the
ECANCELED stuff
> - E(ECANCELED), /* ECANCELLED */
but I only see this removal?
Otherwise looks good.
Rasmus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] printf: fix errname.c list
2021-05-17 8:07 ` Rasmus Villemoes
@ 2021-05-17 8:46 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-05-17 8:46 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Petr Mladek, Uwe Kleine-König, Andy Shevchenko,
Andrew Morton, Andy Shevchenko, Linux Kernel Mailing List
On Mon, May 17, 2021 at 10:07 AM Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
>
> On 14/05/2021 23.34, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > from EDEADLOCK, and remove the -ECANCELLED bit completely as it
> >
> > diff --git a/lib/errname.c b/lib/errname.c
> > index 05cbf731545f..6c5c0aa4de75 100644
> > --- a/lib/errname.c
> > +++ b/lib/errname.c
> > @@ -21,6 +21,7 @@ static const char *names_0[] = {
> > E(EADDRNOTAVAIL),
> > E(EADV),
> > E(EAFNOSUPPORT),
> > + E(EAGAIN), /* EWOULDBLOCK */
> > E(EALREADY),
> > E(EBADE),
> > E(EBADF),
> > @@ -38,8 +39,12 @@ static const char *names_0[] = {
>
> somewhere between EBADF and ECHRNG I'd expect a hunk dealing with the
> ECANCELED stuff
>
> > - E(ECANCELED), /* ECANCELLED */
>
> but I only see this removal?
>
> Otherwise looks good.
Fixed now, v3 coming. Thanks!
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-17 8:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 21:34 [PATCH] [v2] printf: fix errname.c list Arnd Bergmann
2021-05-17 6:26 ` Andy Shevchenko
2021-05-17 7:38 ` Uwe Kleine-König
2021-05-17 8:07 ` Rasmus Villemoes
2021-05-17 8:46 ` Arnd Bergmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.