Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp218796lqe; Wed, 27 Mar 2024 03:59:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8QHXuBZOkRE1FtDsm2tYTwH4T246qgvteBqdbLdceWjp6QBj+58TRaFKWSYppwCR/dfwiFOLVGaGTwklJ0B78pe3NmtulqBVoe/LElw== X-Google-Smtp-Source: AGHT+IEJOYHeScRRBSh5Df4cvJ7YaOXRDh7+LMZMuCDf532QWur1f/I6gKuNPFm+VFM7ND3iQo2z X-Received: by 2002:a05:6512:602:b0:513:39a0:1fec with SMTP id b2-20020a056512060200b0051339a01fecmr2407686lfe.66.1711537140417; Wed, 27 Mar 2024 03:59:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711537140; cv=pass; d=google.com; s=arc-20160816; b=ZLMB4QTL5uWBC9nDAQD/uIW6QIXpEqq0zvtahZgzkzypmEMQP03XH6bAQAaWgYhoOw NocnfsbmOkhRd3h9gvRyDIJKcUTcubpn2fBL6Y+2YitGdToOQCpTYruIy7S4tsx4g7nK mumH0ttCgbdpnOvETUSe43VrQEhdMLsitgFpa+hRfy3pm4dCSlpY1IS57KXX7AYfGjpO 0/tiY+x3LupLdnK533N1Zdk4g5reehLuG7COL9/eBg65Uxqbf1CNrqSH4Q6/yjtDiKh2 rQ+uudg9771+FmfMRTVuWipi5tx4xL6ybRM8iY9WcWGz7wWyt4incwbkT1hBiq0lZNfz 7Itg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=LdBJoZMB+M+m7as7ulZ/MHo9uJhY03Nr+jTBbOpnN74=; fh=XP7HcL9POHIVGyxkBk8N5uwES23Gg1q2YsmQKUAGyg4=; b=UskVs8F/lcuVizNwKFuHMu0i0ccUcTbR9zaQY06oD648+TbZmk/4UTDJ6L1NaQFIOT Aq48IR8RB9JHOnbXnqgYBhC9GoEyrM9X9yRFsPOOzvH1L9/eXOgF6eUBwsTKg30AuOSr V70lUHycoQ3HKZw8wlAu1XhhbeNkMIox9mb8Vgi29rWfHgapqAk66WIEcCiwrXJ9fGhs yo1zP1TLmxBg42JXEwIVJ42qscLHbEYgmUB7H/buu9pQiT0gj2OfHIVJkVzj7WFtBSjK ECdrx+RQsDCgVw+bXT+hI5Hlz60l0HBoV4ytb6oqJnngkYkU6MKdtItcQKOkvx6VLrrO 7JTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JDOjXZSJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-120703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gb37-20020a170907962500b00a474e093ef1si3794239ejc.252.2024.03.27.03.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JDOjXZSJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-120703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ED4861F275D0 for ; Wed, 27 Mar 2024 10:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 758AF4EB4F; Wed, 27 Mar 2024 10:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JDOjXZSJ" Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 046941E88D; Wed, 27 Mar 2024 10:58:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711537132; cv=none; b=YNcnIZE8q0cDaP5DJm5nyQm36CedK0moMsGCDh4Mar21QU3JvrKNXPsUc0uhs6g7QtgHP6fXEeTfD2Fm0lf6fDE/b0UNvrRL+McbTFFg4BuIyIAPRTCJTkjIFbxxUgOUC7IbzWVBqkJbOmlqBkLq59jIiTbz6VQb4nWi53ZHkNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711537132; c=relaxed/simple; bh=FPOIGS3XU/PJpUjx1JSgCVFLz7sjFzTxaraDc1Cj4iA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=t64uLlr6bZzyFQSD8oHuCpe5bxwUrU7w7U+Zvs75QDA1wlt5MU/VoSaLB8PT4Nwt4yK549eKa3j5pkDap/jUWd62KLHivseZ84fpYZOhKo7JxomDb/7JJ8wfefjTBTwoS5IKhxOuiADL0iazaEppimjB6Oia3JAWHz7F4geuQek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JDOjXZSJ; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-56bb22ff7baso7764019a12.3; Wed, 27 Mar 2024 03:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711537129; x=1712141929; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LdBJoZMB+M+m7as7ulZ/MHo9uJhY03Nr+jTBbOpnN74=; b=JDOjXZSJ6ipTc+oszly/nqhiauUcyyEHiXfbOJgzP9F4O1ufqG5IXz7pmmidLIIFSE U36O/G8lXfLoD+EqUVCC0mnR95IRvyS1lIVXcFbx3MNt0OVV1TcwNNoY5X9f6Rfbdjxi xcK2HplxTqO9NnygWMN61IccVe6iKXb/lxgFqiFpO8wL8Jeokpg5mWsFcVZo3rqy7NyP 7wJ8SkIF4zv9ESGl+24JKqnAUJ9konTmaGeDv9nqDEUnCbCacVy1DJvs4roBq+tmmq6r vMYq9BlK6XEUoZIhU0B/81sFzZ+b+F585rJCgjDRcasdiX89WGFO1+D73ys8TIpwwx4O 9Ohg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711537129; x=1712141929; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LdBJoZMB+M+m7as7ulZ/MHo9uJhY03Nr+jTBbOpnN74=; b=vGWKzsaKAp7AL26b4MrwKaNi8uOFdmeV+r8M+BuCr9JuyuqKjqIjWBQR29el8cWAe9 wThjrzqEeCzXe3uh9UO9dCQZ+M2KmZ4g5bkH1+bOOZtsUrFOPPQ8QuGymZQo3nwEGG6U NVOqoJw8o2Z/PBLUZvDvDGepR5zgdE+4rxBXW51W1DkIuq9U3DhIv8S2KdFDnoptx8T0 yA39onSmkuL+iucHH+rvs1/S/g9fHcdLhDZFvRd1stAghZ0TIDKqrZGpv3R4cmoSnRNN cw908CJLMHSo0uq1S1g7CWU9/zNpFyKwvNncpPUD1e9GOs2dLgFFh4XO7wCNQZWXi98Y Ljnw== X-Forwarded-Encrypted: i=1; AJvYcCXy7BZQjdZuJuvoV2h7O4ZhYLTOwqI83DrBKG7NmSX2iAz3BrSD1J8h9noZ0Bn8P9fsTOAgsSrB8UX3u53hqOclLfLdAhVKneU8XEVw9G/eLSVEIQxGc2tk/n2Nz5BNhcE5Hx63OOCTbTotrLs/O51MAw== X-Gm-Message-State: AOJu0YzcHC364rJQ0Gk4Cbh553RXdFN2yWt5UIS8+25zSi+SYLneqYBD VXBGyzM4KgszHLXsogvci4vyL6B8SgJib3eWp/v1n/tdqDb+aaJ0qHwiKgiUUX8sXE1z17Ih1Nr OiWp4lbEXwZfKCh0YBh5Ej6L94wA= X-Received: by 2002:a17:907:9689:b0:a4e:dd7:4e24 with SMTP id hd9-20020a170907968900b00a4e0dd74e24mr35601ejc.23.1711537129044; Wed, 27 Mar 2024 03:58:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240326223825.4084412-1-arnd@kernel.org> <20240326223825.4084412-6-arnd@kernel.org> <20240326230511.GA2796782@dev-arch.thelio-3990X> In-Reply-To: <20240326230511.GA2796782@dev-arch.thelio-3990X> From: Andy Shevchenko Date: Wed, 27 Mar 2024 12:58:12 +0200 Message-ID: Subject: Re: [PATCH 5/9] surface3_power: avoid format string truncation warning To: Nathan Chancellor Cc: Arnd Bergmann , llvm@lists.linux.dev, Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Maximilian Luz , Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 27, 2024 at 1:05=E2=80=AFAM Nathan Chancellor wrote: > On Tue, Mar 26, 2024 at 11:38:04PM +0100, Arnd Bergmann wrote: > > 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. Th= e 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 d= river to platform/surface") Hmm... Is it really a move patch (which by title should not have changed the contents)? (I haven't looked into it, though.) > > Signed-off-by: Arnd Bergmann > > --- > > Not entirely sure about this one, as I've never used escaped strings, a= nd > > don't know if gcc is correct to warn here, or if the kernel defines it > > differently from the standard. > > As far as I understand it, this is a false positive because clang does > not understand the kernel's %p extensions. Yes, %pE here is special. Btw, what has already been discussed a long time is to have a validation plugin in the kernel to check those %p extensions, but IIUC nobody committed to it. That said, the patch is most likely incorrect. > GCC does not warn for > overflow or truncation when %p is involved but the clang developers > chose to intentionally deviate from GCC in that aspect while sticking it > under a separate diagnostic that we could disable. I sent a patch that > did so some time ago but I guess Masahiro never applied it... > > https://lore.kernel.org/20231002-disable-wformat-truncation-overflow-non-= kprintf-v1-1-35179205c8d9@kernel.org/ > > Consider dropping the changes that fix non-kprintf warnings and > including that patch as part of this series. --=20 With Best Regards, Andy Shevchenko