Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp91626lqf; Tue, 26 Mar 2024 15:42:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWePvCWJcfYRNJM9F3yimn6VdNXGjmV8iEYtKsoPhBUzlg7mgCCQ7EDpEoxR5McZKI/Ek5h3m4qVxYTuU69W/iMCw/Vzgzdw1FBN+b8/g== X-Google-Smtp-Source: AGHT+IF9DS08Mix+SaYguqpgvU+0yFZpO8YCi3fU43ivXYDc4S/HwgRDX1fYMxfSmITB3IkomoV8 X-Received: by 2002:a05:6512:282a:b0:513:5978:6919 with SMTP id cf42-20020a056512282a00b0051359786919mr1984068lfb.68.1711492930163; Tue, 26 Mar 2024 15:42:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711492930; cv=pass; d=google.com; s=arc-20160816; b=t89+K0WHDUz3gFmYXXzsgjQJMSs6a4ccE+ayIEJClCffHY1wATWZjw5QSzAUuSgWbs ofB2b2+NYgLWfzjoESCAsNR2BNskO8QV9KMnsFbLGdB7IuS1R3pMBFO9wpooAGgwBvA1 ROFxUoUydukKcu/RRF+sjCPqXSzuSNamK1uGuQfRJ5ySykiCODhBqF/f32TDbybLhzTS QEFrhs0XnHWpoCl7DVxt+sqCxmLNjeEzOLTyntvM9X3DNJ/RuVd8LTwcxexRBUn8nJQb sWvaromhu97ufLqfKAVaP8Y4WNhZ6LFiz20e7FtjZFPV+x/84SjasepnshgXoqh8PrMG YJFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1fHs/oJbPnPDT1/NTnW/KtHH8So26/3vrXv/wInUED0=; fh=F5X0eENT8sE5EoxTGSwYGPIw3GH9fFJv493PVt7b5cQ=; b=LUWqHaTCb+26ed8LTDqW1hd0kM59B/ygguxGR45gOa3cPTewAg6K9T0DOuiu8xhKhN phmO5UGmva86hbF/UpKX80MVj8b/O1HQIrQEwq0KnWd+7mo9obLS8rovUKnqdRRDb3uU EhI3omPkhcEC9nmA6oRFjR092kULqjzzOd0GF25kR8twWAW2IgZhQaW6K26G7ralrVP1 LpvlpT5Jt5ZCYD7WK93gzy7BlwS5ckfhm8Pe7WevQ9H6PwGtdDtHjdpB2JdGAeItOrSV tNUFyoJ2ELOo0M+DsFzraeVX8VPqTh8rNbANnMvRDlI6UYBexf47YGr0A0TXkDSgkCxo 4ozQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p5j6UdWx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q3-20020a170906144300b00a46cf63d977si4059118ejc.372.2024.03.26.15.42.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 15:42:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p5j6UdWx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D99EF1F25634 for ; Tue, 26 Mar 2024 22:42:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31AE413E6AC; Tue, 26 Mar 2024 22:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p5j6UdWx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 381B713DDAA; Tue, 26 Mar 2024 22:40:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711492838; cv=none; b=h00sRcB+x1aOEqwFhPyEqnKnjZG8Ygs6JFGUkyrSs5JiQlb65KyXQWZ/e8jiGmZHLl+rBw1xMpkZBGqM9d8nm434ZMcseA1aWKtDrg4qHFAfbMnDtBt3e3vsWBjZjRKLWfc6m0J64c5XGzcS6bKG4RyYNh15FCYJYOo9S6tFbUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711492838; c=relaxed/simple; bh=DvdOaxXySSb88hE1tdZLq/K7+rtZJ/+uDHjNaQDuU0M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jvr5W81AGEkxwkYEVdxJOP8MbhmPr2qJLTcrDNn9BXwKlrPGEcxQEuDtTw73c1Z+6eEtQMng1kU7Dn55gyhN2PAX/XQQMTP8pRofRr3jl5/z6tWtYCa4o1mH5EVuGcGKTuk+BqcfTATlsKhRkMMdLu15JwI0mitO2vxEZJNLbhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p5j6UdWx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F56C433C7; Tue, 26 Mar 2024 22:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711492837; bh=DvdOaxXySSb88hE1tdZLq/K7+rtZJ/+uDHjNaQDuU0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p5j6UdWxGLPCw8MD1MG7G52pz4jf9eUDs/fFAPZ0nSxoBq4yXx+Or5Lgn1xXUeElp +cj8i69kiAsbFcByaE6X3MwtRtceTT9Edu4WzpCWxVfQyKIQliXEXJ9jaPuhdPt1EO hPTTraFVvOo4PuszlnUsVbUVQUggXvzt/b36cPf3IquLaD83kojbUDODfNp+wT8Qnk rI2SfYkMFrUIaTNggJBf3zCEFOjGEO3szpfqF7F/VaaNyAUHWaDczx4OxbnERjzweR DJEEn+vReYcCj0bTRNiF21fVJnOstGn5xp5kbalE8IMqei4+oKEuSso3nQa0xJ0jNL NVn1p1MByEg6w== From: Arnd Bergmann To: llvm@lists.linux.dev, Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Maximilian Luz , Nathan Chancellor Cc: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] surface3_power: avoid format string truncation warning Date: Tue, 26 Mar 2024 23:38:04 +0100 Message-Id: <20240326223825.4084412-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326223825.4084412-1-arnd@kernel.org> References: <20240326223825.4084412-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann clang warns about printing a pair of escaped strings into a buffer that is too short: drivers/platform/surface/surface3_power.c:248:3: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 12 [-Werror,-Wformat-truncation-non-kprintf] 248 | snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf); | ^ Change the format string two print two less bytes so it always fits. The string is still truncated, so there is no change in behavior, but the compiler no longer warns about it. Fixes: 85f7582cd484 ("platform/surface: Move Surface 3 Power OpRegion driver to platform/surface") Signed-off-by: Arnd Bergmann --- Not entirely sure about this one, as I've never used escaped strings, and don't know if gcc is correct to warn here, or if the kernel defines it differently from the standard. --- drivers/platform/surface/surface3_power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c index 4c0f92562a79..72f904761fde 100644 --- a/drivers/platform/surface/surface3_power.c +++ b/drivers/platform/surface/surface3_power.c @@ -245,7 +245,7 @@ static int mshw0011_bix(struct mshw0011_data *cdata, struct bix *bix) dev_err(&client->dev, "Error reading serial no: %d\n", ret); return ret; } else { - snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf); + snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%4pE", buf + 7, buf); } /* get cycle count */ -- 2.39.2