Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp1236365qto; Thu, 27 Jul 2023 08:33:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUf1Fv4h1kb1I9CMnyLB5bBY0zq8nxl8XbcqynFJd1HGWlIBDfGCmA1kVRydHLaOUi9ZQl X-Received: by 2002:a17:903:124f:b0:1b8:1c4f:4f8e with SMTP id u15-20020a170903124f00b001b81c4f4f8emr7312876plh.53.1690471970831; Thu, 27 Jul 2023 08:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690471970; cv=none; d=google.com; s=arc-20160816; b=SvwQ7d3343bcQZOgQBE3wZJazWI5pgnZzAz94IS/d71YOMjVwpiYYDzV396zkK/BrU y7AWbNsBk3vt94HGxX288wMhIXlpxWiwaH2zAYGiH/ROw4pnpeKZ9WVvOHW/kRqfACVy +FKR9rIDetIUUU8ihvkJSR+TcaeLfmhBnelUjgUQUEcbeDejnNrm+wW5Mzn1h9+j3Y0M NdLp0FGBSky3ZwvyLtLm3DnP7lxZY/xRIYYoHFFxF1SE4T8xKiXXcf/lktpmVo95uyjl 724fWx1A9wFcqNgUjDerWsvAtklCb6YET8ThzvKgxjlGa+GPi3XyUa9/IQXCCtCnm+EK gqtQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NNG9tje3l3xvzkqp9p4Pdm+9j03eaDrBKVPPDevDw7w=; fh=sXHvCLIDuseusQ0NNA2O/ICIVbfTu1GQojDD5X7xjN8=; b=pZFOmKfcgEMtdT7iGtsnCTHufXrdHq5urM2TJ6UqEFqcDDEwG+ib08JeEDNF9byfbx LG15W2Mjy83GzFeoRYWcIdCXRA8UDq6imWdZjm3a93eis0wwJrokylIavr0V9+GCcg/P OplrTIwO4dr/O3jiCPnQAR/h5GK3wEgGWInCaheWAMqo+6EcO9cLpwOXu0vY6RYv6AQE qIBsDB3iRfW6bpmRbdtXniPfewipErBD70pEHs8nbQxLxMfqZOMXZ6k/0EsKbDMWQLc5 KR+1mX/kIHCq0UeqUmjgcjX/y0438n0TwnqxDR82LS6T94cAcjcxREJk5HymrmrCgOZ2 Xz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=a8isnEEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kj7-20020a17090306c700b001b7f849cd12si1406998plb.81.2023.07.27.08.32.26; Thu, 27 Jul 2023 08:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=a8isnEEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234507AbjG0PRq (ORCPT + 99 others); Thu, 27 Jul 2023 11:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232667AbjG0PRo (ORCPT ); Thu, 27 Jul 2023 11:17:44 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 802931B8; Thu, 27 Jul 2023 08:17:43 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 92E5C60007; Thu, 27 Jul 2023 15:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690471061; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNG9tje3l3xvzkqp9p4Pdm+9j03eaDrBKVPPDevDw7w=; b=a8isnEEHtGmLESwkXnzgHu0zmOpF5SXA6XP6oLmnOaOB1NpUhdjXq+lDqG08hOsvMhiCAH YEyUuVY5aldv26ZSUh6y+CkxEFf1ERZbglj77phxqtrpUCxVA/KVko+8jZUCaipIxNYuqw JN1ddb7ZXDTXbFwdVL080k2EYfyfxz4kMk8AU1+ouspuqrgeIqNCzUDR488no7iZEpU2vR KjXU5qUOULncJ4Suzpdkxg1MpctDH/yPuVmtrTnG02ZswGZODWuij9dKVKNpyv/5vmuTuB +AbUa1TBEMTWdvefjTzngTIPUtsdm7pyI3Cu8LZ3aG4M7pjtr4rstY/LhPuUuQ== From: Miquel Raynal To: Arnd Bergmann , Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Arnd Bergmann , Peter Foley , Pedro Falcato , Michael Walle , Mark Brown , Takahiro Kuwano , Dhruva Gole , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: Re: [PATCH] mtd: spi-nor: avoid holes in struct spi_mem_op Date: Thu, 27 Jul 2023 17:17:38 +0200 Message-Id: <20230727151738.586338-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230719190045.4007391-1-arnd@kernel.org> References: MIME-Version: 1.0 X-linux-mtd-patch-notification: thanks X-linux-mtd-patch-commit: b'71c8f9cf2623d0db79665f876b95afcdd8214aec' Content-Transfer-Encoding: 8bit X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2023-07-19 at 19:00:25 UTC, Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc gets confused when -ftrivial-auto-var-init=pattern is used on sparse > bit fields such as 'struct spi_mem_op', which caused the previous false > positive warning about an uninitialized variable: > > drivers/mtd/spi-nor/spansion.c: error: 'op' is used uninitialized [-Werror=uninitialized] > > In fact, the variable is fully initialized and gcc does not see it being > used, so the warning is entirely bogus. The problem appears to be > a misoptimization in the initialization of single bit fields when the > rest of the bytes are not initialized. > > A previous workaround added another initialization, which ended up > shutting up the warning in spansion.c, though it apparently still happens > in other files as reported by Peter Foley in the gcc bugzilla. The > workaround of adding a fake initialization seems particularly bad > because it would set values that can never be correct but prevent the > compiler from warning about actually missing initializations. > > Revert the broken workaround and instead pad the structure to only > have bitfields that add up to full bytes, which should avoid this > behavior in all drivers. > > I also filed a new bug against gcc with what I found, so this can > hopefully be addressed in future gcc releases. At the moment, only > gcc-12 and gcc-13 are affected. > > Cc: Peter Foley > Cc: Pedro Falcato > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110743 > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108402 > Link: https://godbolt.org/z/efMMsG1Kx > Fixes: 420c4495b5e56 ("mtd: spi-nor: spansion: make sure local struct does not contain garbage") > Signed-off-by: Arnd Bergmann > Acked-by: Mark Brown > Acked-by: Tudor Ambarus Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks. Miquel