Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp130448pxx; Wed, 28 Oct 2020 00:01:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU2IILgV9NdK2sdaVhOXW7VAAFfrk1KEraHSwIgyPFdTHMR9rZ1/Yljp9Bc+O0Vv35m07K X-Received: by 2002:aa7:d1c4:: with SMTP id g4mr6233947edp.198.1603868489320; Wed, 28 Oct 2020 00:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603868489; cv=none; d=google.com; s=arc-20160816; b=Tmie2TWhNtGNiQumZoQFixPNiKSrWHWCv8f8HUzSdjB3kKeskE7MxCWiZu8fBKUH0Q aK7CcGFKxJNNDLE41HofWo/I/sGUGP3JC9xtzl4YGXyfR5f+Cj3yoQK3FtVTZYmoVZG2 INnklB8jeSLSfflyahNgQgkkoebK6JrnB/nAaNm3eQr5n6B1HTTrkuAIcwyJZhx4y66D kdjzc/sbxNmPLTm7VSQoyF0mwE4qChOut+gr0JP+OnAgUnRr+OPh3k217F6P4vekuxqe Tg3q72Nqd1CUQ0Jw4tgXqRxWIwJhM9idcVU4h85XMqKXKGGqeTrEbZKty0Upk9uhJU7q g0cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=o95UznsIXvrtNAHbiwH0VAgmFKpGNUfa3i03AXLJKRA=; b=p4HoqyduHnBlWfKGXwfA1etC5CK/ec2V13PxvB5q7UGUiD+8pbEPV772cnDWDp/JZl qZJ5Ppvx37uBrqvI9p2SZymWyZ1jwy//i/rOyP8PUYKbR+IMysCBAJG+8ekNqxaxWVJ+ Gw4OLlx0wWc6QvrIV4WBClgUaH7gv/MsnGKwf0L2A1mgz68vgpPB679fm27GujhzzQpv X4VHtVny7idnUo1O812MueArQKejh0Y04Fuc4AB/koWCk5VK3zheV0tVlrGH43yzByRu dT97gmNqR3XudxEtj8hjWaCiU8A+6TonwelIsgcTBkvBCKkmMCycjP175xeNS5CDefOE jSbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=F8qJRAmo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh27si2798130edb.28.2020.10.28.00.01.06; Wed, 28 Oct 2020 00:01:29 -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=@rasmusvillemoes.dk header.s=google header.b=F8qJRAmo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2898795AbgJ0K4I (ORCPT + 99 others); Tue, 27 Oct 2020 06:56:08 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39049 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgJ0K4C (ORCPT ); Tue, 27 Oct 2020 06:56:02 -0400 Received: by mail-wm1-f68.google.com with SMTP id d3so942116wma.4 for ; Tue, 27 Oct 2020 03:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=o95UznsIXvrtNAHbiwH0VAgmFKpGNUfa3i03AXLJKRA=; b=F8qJRAmoYAvlvuoSU0RTOEd/yNJJjS8z/Ay6CKw0wtV3l3HG96/HDZX+NmFuyI5JrX Oim+WCTWxuA505uJ7woBZnZbMl8DX/Role875kIvXZPDhGbuVOMrm//IF/Ljw5DvECPE HoeiRCkB2HdYExBfxodUSb8dss5sZLRO8Pwds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=o95UznsIXvrtNAHbiwH0VAgmFKpGNUfa3i03AXLJKRA=; b=C6JHkM4fgDAoG+kZJ19NcPIFxN44SV230dOUby9zJql7i64J1OHADFQu52gluqDh78 pIgE0HmWLSEGlZO6TdwAhcDJqI44GT2YTEwBQwM3/ZP0z35lK1GPaSGm/BYb1SDmlJE2 ton+T03qTNKFdXqAgGhZED9i/8OVX+GR6bth79E9NZTohhIgGmH4zrElw+hbuU6rTvLt REa93ZJ4YDuvAzGG7EcInfIJUGl+JDmroblM/x0S1InhBgsJch92kMLxGIYzWU06kJi+ Hx2lFgJc1rigEKe4B9rgFHQ9sqkDA+hA8u9irKwXZTUh3oUoqhT1RwT4tD/8Y7hGs2fc 46GQ== X-Gm-Message-State: AOAM532vmRbBbb4lAGVYxxqdFZDx/CA49Pkf+1buSpzgsFFAolAQCnFl JYnl/LLOsNuRhfBLcWm74HPUfHvVvgMm6khcyvg= X-Received: by 2002:a1c:20d0:: with SMTP id g199mr2170254wmg.38.1603796159522; Tue, 27 Oct 2020 03:55:59 -0700 (PDT) Received: from [172.16.11.132] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id u9sm1557607wrp.65.2020.10.27.03.55.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Oct 2020 03:55:59 -0700 (PDT) Subject: Re: [PATCH] printf: fix Woverride-init warning for EDEADLK errno To: Petr Mladek , Arnd Bergmann Cc: Andrew Morton , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Andy Shevchenko , "linux-kernel@vger.kernel.org" References: <20201026215004.3893088-1-arnd@kernel.org> <8f5c673a-0265-a6d0-57fc-98c788caadc9@rasmusvillemoes.dk> <20201027091218.GB31882@alley> From: Rasmus Villemoes Message-ID: <13d87c71-66b2-2abb-825d-6e8e2e47d22a@rasmusvillemoes.dk> Date: Tue, 27 Oct 2020 11:55:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201027091218.GB31882@alley> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/10/2020 10.12, Petr Mladek wrote: > On Tue 2020-10-27 09:46:28, Arnd Bergmann wrote: >> On Tue, Oct 27, 2020 at 8:23 AM Rasmus Villemoes >> wrote: >>> On 26/10/2020 22.49, Arnd Bergmann wrote: >>>> From: Arnd Bergmann >>> >>> NAK. That would end up using the "EDEADLOCK" string for the value 35 on >>> those architectures where they are the same, despite EDEADLK being the >>> by far the most used symbol. See the comments and original commit log, >>> the placement of these is deliberate. > > Good point. > >> Ok, I see. >> >>> How about we do this instead? >>> >>> when building with W=1. As the use of multiple initializers for the >>> same entry here is quite deliberate, explicitly disable that warning >>> for errname.o. >>> >>> diff --git a/lib/Makefile b/lib/Makefile >>> index ce45af50983a2a5e3582..a98119519e100103818d 100644 >>> --- a/lib/Makefile >>> +++ b/lib/Makefile >>> @@ -224,6 +224,7 @@ obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o >>> >>> obj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o >>> obj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o >>> +CFLAGS_errname.o += $(call cc-disable-warning, override-init) >>> >> >> This works, but it disables a potentially useful warning in case we >> get another conflict in this file, so I'd prefer to find a way to >> avoid the warning rather than force-disabling it. > > Yeah, I think that it is better to explicitely disable the less used > variant in the code than hiding the double initialization. It will > be clear what is going on. > > >> How about adding the #ifdef around the EDEADLOCK line >> instead of the EDEADLK one? Something like >> >> diff --git a/lib/errname.c b/lib/errname.c >> index 0c4d3e66170e..93043fb960cc 100644 >> --- a/lib/errname.c >> +++ b/lib/errname.c >> @@ -38,7 +38,10 @@ static const char *names_0[] = { >> E(ECOMM), >> E(ECONNABORTED), >> E(ECONNRESET), >> + E(EDEADLK), /* EDEADLOCK */ >> +#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */ >> E(EDEADLOCK), >> +#endif >> E(EDESTADDRREQ), >> E(EDOM), >> E(EDOTDOT), >> @@ -169,7 +172,6 @@ static const char *names_0[] = { >> E(ECANCELED), /* ECANCELLED */ >> E(EAGAIN), /* EWOULDBLOCK */ >> E(ECONNREFUSED), /* EREFUSED */ >> - E(EDEADLK), /* EDEADLOCK */ > > This should stay :-) > No, Arnd moved it next to EDEADLOCK, which is fine (it can lose the comment /* EDEADLOCK */, though; the comment on the ifdef is sufficient). Especially when: > And we should remove the ECANCELLED definition. It is always the same > as ECANCELED and replaced. We do not define EWOULDBLOCK and > EREFUSED either. Yes, I'm not sure why I elided EWOULDBLOCK and EREFUSED but not ECANCELLED. So let's move EAGAIN, ECONNREFUSED and ECANCELED to their proper alphabetic place. But I also want to add a check that the things we've elided match some value that we do handle. So add something like #ifdef EREFUSED /* parisc */ static_assert(EREFUSED == ECONNREFUSED); #endif #ifdef ECANCELLED /* parisc */ static_assert(ECANCELLED == ECANCELED); #endif static_assert(EAGAIN == EWOULDBLOCK); /* everywhere */ so that if we ever import some arch that defines EREFUSED to something other than ECONNREFUSED, it would be caught. Essentially, errname.c should mention every #define E* that appears in any errno*.h. Rasmus