Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1095170pxj; Sat, 15 May 2021 03:49:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgc92OHD+wcr6meoFc2RT+/kxxOHKX6Sv5U9hN52TKu/5r6XuQX/DeI5zwdkPlih6tU9oA X-Received: by 2002:a02:c73a:: with SMTP id h26mr327276jao.95.1621075753780; Sat, 15 May 2021 03:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621075753; cv=none; d=google.com; s=arc-20160816; b=kssE3NHdmBqKLpA6rQ8pB6suS1EQ8n+A/iRZt0EqRqdnHDQkNZaoZKUQjCyDSnaFY4 nmQcxP/aKLvXxzBZtjrmEgmI5WHHP2wVi+WtiNDIsXwjA1mzhdblOPgCU9GHYjBFsyL0 6z9Ebnffyy+QzQnVr0G9nvuBdf6rmwbCD15LTfhEvfuLZ0d7IslTsJqYgUNB0k8cCV8y AnZSGw6zAMTUw3XlpU7M+iE0tlLnfcy6MjsckC/r1sk9gptjWkrPrNRGmcGxhuRfoI50 AtwqXDfvRfSA4OPWGB3xah2MsH0E/SMF4G1hYc0VXX44Jp4ZiO+P7BNjqwn0Fmv+lsZm RU5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SnG/9WddezV19C7gBW0Iqhb7yAYeWnoc+50maMXw0M8=; b=nHGCL71GEbYbj5p385aCfdlJAGL/yOM0kex/SfSkPz0PMNzizzIe34jmv+q1hRmOqh DNQpyfJdg6CIya9PKswpoyToovADrgW124E3OKi6SgZzYfFOQXLydm4mAHw1rcfxcgw2 sQ9pI8cMhCZnRhVWDxWhb1M79N07gscTQw8ExdoJa5jEI2mfTQTHDjkgBppBFjdR3Nax 92WqfhqLeYpR1NprpXesERrZ1+okGxZk/33EH29lndGGyIqWFYjaqofbr9zus69cmT/R 0cDKKFsFtP/6OwHM7mUR7xRNOdWNzHRnwXyWpyhO6QuaURCKrwXRcqwcKzRdTbNL8iHY ddFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pYGZ+Jr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si9958298ioi.7.2021.05.15.03.48.43; Sat, 15 May 2021 03:49:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pYGZ+Jr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233520AbhENVhE (ORCPT + 99 others); Fri, 14 May 2021 17:37:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:57358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbhENVg6 (ORCPT ); Fri, 14 May 2021 17:36:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 132906143F; Fri, 14 May 2021 21:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621028146; bh=00pu7fRzCavIm91cklhq4VrgHJQZBLYX+VMMn4KhGm4=; h=From:To:Cc:Subject:Date:From; b=pYGZ+Jr7YjP1bG+HBKIAjo49/PTMRO2cz+j5tRYrAXcWYaq5WABr8L8AAc5VsbPJR GrSBAkjzRKJBJbd13W6W2kZOCwWqvUS2YqT5Pm0A9j4QNSlwx5+GKjTjHsZLTgq0Xv Mi2/Q/g53b+chnQY9jzrkdeoGTr9cPBbFb7O2lKnzi3bdK5y2xm84HZp94oeJfkiLD E5be6c6pP6oOeR5mgNp7hieUMhxy3TxsDNlfIiVU3QN0PQoo35iuduJ/wDeFzIkELT 7FOz32wa1AAjYUlkkbkoT7JwmDcSAKS44eEWR+3rcy75bdQl8Z/Gk8N3ztCZFoyvJ2 lHAzW4eQVXqWw== From: Arnd Bergmann To: Petr Mladek , Rasmus Villemoes , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Andy Shevchenko Cc: Arnd Bergmann , Andrew Morton , Andy Shevchenko , linux-kernel@vger.kernel.org Subject: [PATCH] [v2] printf: fix errname.c list Date: Fri, 14 May 2021 23:34:50 +0200 Message-Id: <20210514213456.745039-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: 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. 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 Suggested-by: Rasmus Villemoes Signed-off-by: Arnd Bergmann --- 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