Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp922361rdb; Sun, 3 Sep 2023 17:49:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjU7XWhOJqo4F+HpOxlYAeSQMPS0AXY+7/yiWgDGjzbUDiLkRDvY09katUmLT60vR2ey/4 X-Received: by 2002:a9d:7e88:0:b0:6b7:5086:2f59 with SMTP id m8-20020a9d7e88000000b006b750862f59mr9491910otp.23.1693788592505; Sun, 03 Sep 2023 17:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693788592; cv=none; d=google.com; s=arc-20160816; b=YBcukuSnnupAyVBHwpcU7JV9b5EZEsB6CCUMA9acPGPdhwfhpgohT9BIuSGZWMyPOt +w/iJu+OaP8zSDNy8PpvbXA0wfefI0WnHRlST9H5bPVpyuwdDNMuDCy2EIe7ZrKIJyUh vKGvbuxC9TOctIzkgWft6dM+uScBpeyiXhNcwt4N+5bLv/St53wQptwglZ8eWqdu54fL dxjZ6LJCtKjZXzWIXNySHlghw2h4vf03VT0VxwpWr2r8BUveHhKA/MEQk3OucSTBvF8k pBz97ZpHczrZY9usAXKJpFLciUbF8b52S0vO6gkKd6uDOwkJFQZMC9DoglQrvO+WYeZt c2Ag== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=2kFa1ouPRm6YMjtpUOCd3DsUP7NliDjVIHNcYwS2oC8=; fh=t88gye23yuhy4kc43ICdt6cNn/ncdg2ZJi868DDLyXk=; b=yK9unJ2gVsUruBFEADqVC7R9mmaJygK01mDaZ4P2FgewgTt9CRPXFvdZCJPXHTSxsY RE9UyFSkteME7kKj47mYgXYg3OP4Nob94gTi7YBz29WbjOJpRBeiz61nEN8xZLJ+fVSO najhel5PpR+UwcXVkziq29+JpaKeAYMcc3ZCyDYe/pAfX8XBAYBV3Dfzjj6dSdhNKJDg 3EajSLR5RGAAzl34e08cekKgb9RA5s8ykCWLRFFM1A5tT/KXm74tV1l+gyMzIKuWiZe6 QwNP7stkN8vXS6qHE/XaJ0zbHaFqFDpaIZyKl+9QVkWksPt8pnFFTgoiEZsKCsVl4Cgb FVcQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv2-20020a17090b1b4200b002692eb69014si9765617pjb.20.2023.09.03.17.49.37; Sun, 03 Sep 2023 17:49:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343762AbjIDAAK convert rfc822-to-8bit (ORCPT + 99 others); Sun, 3 Sep 2023 20:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbjIDAAJ (ORCPT ); Sun, 3 Sep 2023 20:00:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4B21C4; Sun, 3 Sep 2023 17:00:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF8CE165C; Sun, 3 Sep 2023 17:00:43 -0700 (PDT) Received: from slackpad.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 072F13F766; Sun, 3 Sep 2023 17:00:03 -0700 (PDT) Date: Mon, 4 Sep 2023 00:58:55 +0100 From: Andre Przywara To: Christophe JAILLET Cc: Vinod Koul , Kishon Vijay Abraham I , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH] phy: sun4i-usb: Fix a W=1 compilation failure Message-ID: <20230904005855.658819b3@slackpad.lan> In-Reply-To: <0bc81612171baaa6d5dff58c8e009debc03e1ba8.1693735840.git.christophe.jaillet@wanadoo.fr> References: <0bc81612171baaa6d5dff58c8e009debc03e1ba8.1693735840.git.christophe.jaillet@wanadoo.fr> Organization: Arm Ltd. X-Mailer: Claws Mail 4.1.1 (GTK 3.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 Sun, 3 Sep 2023 12:11:06 +0200 Christophe JAILLET wrote: > With gcc 12.3.0, when this file is built, we get errors such as: > > drivers/phy/allwinner/phy-sun4i-usb.c: In function ‘sun4i_usb_phy_probe’: > drivers/phy/allwinner/phy-sun4i-usb.c:790:52: error: ‘_vbus’ directive output may be truncated writing 5 bytes into a region of size between 2 and 12 [-Werror=format-truncation=] > 790 | snprintf(name, sizeof(name), "usb%d_vbus", i); > | ^~~~~ > drivers/phy/allwinner/phy-sun4i-usb.c:790:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16 > 790 | snprintf(name, sizeof(name), "usb%d_vbus", i); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Because of the possible value of 'i', this can't be an issue in real world Would using "u8 i;" help? After all currently there are only 4 PHYs max, and in general this isn't expected to be more than a "handful", so 8 bits should be plenty. An unsigned is better anyway. It leaves a bit of a bitter taste, though, as we shouldn't do this kind type tweaking, especially not to work around the compiler trying to be clever, but then not seeing the whole picture (that "i" is bounded by compile time constants not exceeding "4"). Cheers, Andre > application, but in order to have "make W=1" work correctly, give more > space for 'name'. > > Signed-off-by: Christophe JAILLET > --- > drivers/phy/allwinner/phy-sun4i-usb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c > index ec551464dd4f..e53a9a9317bc 100644 > --- a/drivers/phy/allwinner/phy-sun4i-usb.c > +++ b/drivers/phy/allwinner/phy-sun4i-usb.c > @@ -782,7 +782,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) > > for (i = 0; i < data->cfg->num_phys; i++) { > struct sun4i_usb_phy *phy = data->phys + i; > - char name[16]; > + char name[32]; > > if (data->cfg->missing_phys & BIT(i)) > continue;