From patchwork Mon Sep 27 13:15:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514687 Delivered-To: patch@linaro.org Received: by 2002:a17:906:f46:0:0:0:0 with SMTP id h6csp3931647ejj; Mon, 27 Sep 2021 06:16:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmVo3hk53DP3gHTDXKjbyE6Bi5Vd7KrlbR9z9zDddyZXN19ClIouLQENa8Mj1JRNvuHs5E X-Received: by 2002:a05:6402:1c8f:: with SMTP id cy15mr13167099edb.41.1632748563375; Mon, 27 Sep 2021 06:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632748563; cv=none; d=google.com; s=arc-20160816; b=XJY4GeLNulm6mkmYyLEYp+/B2iaLhCpl2UtO0Yr+EW6nLjlac8QPRHFVaDTtY0uG5g 9CF7RP2/oeZ/7r8TiwN4jFlydDnpyeTu6xCPPSQzAtqfwpMB1mbWJeZHh2pla4avSZDR pAaxUWsgzZ9LftX0miCE26j4+tPVuSmqewFToU9tMz8Zey/dpRFvXwyn8XHhhc8HQ88M bCcji2o3sB7sQiaSJqL/1lkHf5j14jfxD6lDec6NNSe+fXQoG8kRq4oJrPWk+f56QmhF 7WrlTW5jBKELxM2L2BsgyIbRP7ind6SJ1mqA5LkrTF5YArzYpDK6yNiVazNoYkxYbKj1 aAHQ== 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=hOEUCY3EE5WxV/t3n/M3ISPZDW1DUEK2IdvlUDxv9eA=; b=Yca5KCm9CSalDwx7E5nU94C1rU1qsY3kNPFlsdfzTvpB81rHi1lgLHfVhaA9qH1Woh or7UJIFpzqKBAogUQyoVrffCuNFbMnYnhFjI+pu3Ymec9X60IcZfZeizwiuKQBvDcX3G fFt1wm0PIKf60ATc4HdyQQkDvZF/cVn+VM/VOPhEvsCOM3L3tHD366gZ78dRNAzmRtdu zMO4098W8odjkiQW57V1oh3204yKsbDLX1fX5Mo+4Uhx6qrNlOkvJWN/yIir6zjBgZW/ +gv0psqf7Hfk6xpU2ByULdBaD/ZU8YNDukwUruZdf4r7nW73vhYUmKAsM1SWpExRFbi/ LixA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IaQDOEbf; spf=pass (google.com: domain of linux-leds-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-leds-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 s27si16157979edy.251.2021.09.27.06.16.03 for ; Mon, 27 Sep 2021 06:16:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-leds-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=IaQDOEbf; spf=pass (google.com: domain of linux-leds-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-leds-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 S230089AbhI0NRk (ORCPT ); Mon, 27 Sep 2021 09:17:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:53102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234421AbhI0NRj (ORCPT ); Mon, 27 Sep 2021 09:17:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 69A9560FED; Mon, 27 Sep 2021 13:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632748561; bh=5s+nTXZSEtYxqsinkY1DskVGn3eXA7KEnUdpZ1oRVnw=; h=From:To:Cc:Subject:Date:From; b=IaQDOEbfCJ0gbkEEAYFTSCjwBt00r61zAKlbTqnvjU3uLQFc9QOw5m8EN0SYoe5+0 qA51HOAArMHxq34BikOhmmo7QH3sf9YHmUdzH13l3udX4JdutnYdHrleWJdFs6Vkgx A4hXA5xphX+GNwMWTuEx79AMyRQNJU8QwixdCitecM4YW1dbF5Ux16SS1dFxRgU8gZ OqMn65aPiXZicOu9I4R+XXEtgyRbhTVLGYnl/igY7G9Eu/Dz34jWcZ5Bz7I8XWLo60 G8AxPNOdknm9FuDB10EYp1mFWzJn1sD8Uuv+kEJiYNhRifjM1IUyHkNRD9tybCSFBP pT1cZnn7mkXJg== From: Arnd Bergmann To: Pavel Machek Cc: Arnd Bergmann , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] led-class-flash: fix -Wrestrict warning Date: Mon, 27 Sep 2021 15:15:47 +0200 Message-Id: <20210927131557.1587062-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Arnd Bergmann gcc-11 warns when building with W=1: drivers/leds/led-class-flash.c: In function 'flash_fault_show': drivers/leds/led-class-flash.c:210:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict] 210 | return sprintf(buf, "%s\n", buf); | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/leds/led-class-flash.c:187:54: note: destination object referenced by 'restrict'-qualified argument 1 was declared here 187 | struct device_attribute *attr, char *buf) | ~~~~~~^~~ There is no need for the sprintf() here when a strcat() does the same thing without invoking undefined behavior. Signed-off-by: Arnd Bergmann --- drivers/leds/led-class-flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.29.2 diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c index 185e17055317..6fe9d700dfef 100644 --- a/drivers/leds/led-class-flash.c +++ b/drivers/leds/led-class-flash.c @@ -207,7 +207,7 @@ static ssize_t flash_fault_show(struct device *dev, mask <<= 1; } - return sprintf(buf, "%s\n", buf); + return strlen(strcat(buf, "\n")); } static DEVICE_ATTR_RO(flash_fault);