From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 75FC630E838 for ; Fri, 20 Mar 2026 19:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033478; cv=none; b=Ezu2Y1A5nlSBP6CpzNCRAXKxnmTvI1Cs4Tz/rgNPYHCrYaQAumcPjVEaZPN6yrHXRLmgdcMZr/dcp2xe+0Jr43PY4GqFKOXoNIcoU+CuvLe5IphvCY1JpT4FLWz+t/Ed6MgoNq5uPnf7RNW9UUQJd1jKai43eUmt/ioyn0hQF40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033478; c=relaxed/simple; bh=y4xjiVBHeQF5JqZbrncshkWLcltuy9g0ZxsUn3RToTc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dSNKnM4fWTmHsr481yG3i/2BFBJ8F5AP7rhei2hwut5FCFBgQzU70Vhiqn3RxdD/zFJaXQm+EmcI6dsbqf5QzXX8W16ItlE+LCTlK9AJCtRnXxfcpiRaCLHS1ibxeQVz34GpWu3I2h+oA/2Mxp1ab865Lr1/nnS/BgJk6kuRBuM= 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=f12mF43N; arc=none smtp.client-ip=209.85.221.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f12mF43N" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-439b9cf8cb5so2991548f8f.0 for ; Fri, 20 Mar 2026 12:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774033476; x=1774638276; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rU8hROsash8pjNenSuRQmTzxfx2+/q618jsTqv5sedE=; b=f12mF43NfOplMF26NlyDg4yYTjXoTv3VrPZ6xJYEXxrg7SENZXSyRQ7bU1Q3PjjAAe gxYKlkUJoWoAKvKMU6iHeLIQzV/SsPFlFWw2iKzfyM/QY6haPg+HMnC8ZGqDH81fkbMX sdxVPwt/QkL5IMbDLdMJP+bbL0EQa0oZFE43Uw727N5cJqPGV6XZG6TkEJ33TI8jIgO/ ovJ42EEzjdI75D/ugCeMxu4g66KyaX3fhvxi7anAhN4q2u4r37xDhCd16BSIQgVWxzP9 IJZioZD7BJfVOn9LdPt+m6Sz+LnQgU4nfAS2FEVeIvkxEZPke2cd3j4wFdNOmdtIEmfT 7hhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774033476; x=1774638276; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rU8hROsash8pjNenSuRQmTzxfx2+/q618jsTqv5sedE=; b=mI9swOMUdaZiYmowJxwwqPf8uYz9ibYtL7rmEO/KorzWlWL6EWZBrYPXWShBL1jAEg cJk22sVt5MTwm9MinVQpiARQcRB0128rG75Gg/sKxdSd3jU7itqPhRg/j0KrPPrjhm/m S+KUlShlSTUZr/YcCs/MnLibwmmFBfb/QTG9+HCCYtqMW6AxyEicAMKJQ1INaB86jq7s E9L0W7Rl9H0Ck451wEqAxw4NpCpDVj0SWypaXh6DojfkWk4Fg9xUeGW2+tY2pKApGQns 9TkN2/IzPoa3vPdtmzJhCPxAU54pzNm+uKF8tzNWHlwWmjeC6+6RY/HF/M06V8jmo9el RQvQ== X-Forwarded-Encrypted: i=1; AJvYcCXKIKXfVxfTmZ+5lLh2J9DzN9gZrNq8e6KzTl100BBvsLx11fvaPBHEaQg5YQ4aeLtrY5N7zebqRlYA14A=@vger.kernel.org X-Gm-Message-State: AOJu0YwuLPQBXInRuitqQmacAzDteXsg4+Q1uoKlze/tzXkbavUiPFnx LpIUUftSa9udZCOHnUPwQ/wcMznVtodRsxXZ9zqmJ8LBeojpiBI1sUw9 X-Gm-Gg: ATEYQzxqmIiDfBGQy/ER803YLAKHpLDt7YxWFKt9NYXrkfuM7XUHsDhNAxiKaIY4U8E TnlA1zlzL2Y9yysKVuyIzHHzNizMAVxoXjv8sl4LDR990/SuURq+DJYT0wdelhzYRBscLQFKOXs ON8Q/4AVoZXvU46vL+d5/ARf+Zfrg26q5vM1EbMpsqcDIs4s6O3IwvZrep4F0Nc7YGho/dQ5h1L BDVQKPkicUAabAk4oQKZi01NvLwkx97bBDbGm5HoQzubukqI61p4O2QqzUbtwoRRmf+ahwM4Soh 1FrQfYXEvmcBB+6o3S7Ugi/rvo1OVRqA1xERSUlFet2WNiT/HgjSG8Bs++H7TZP+2KwRkUA0L+3 PMQ39eS2auzWYx1d4PEHJpD74vL+NuYCJBKrmf6EW5KFHWRFZ/G1J9WiGt4xCW/uGbqXunuv0kL OEVCxaOxAm37Ta+yh58GjWOlSdoxbWUIBfMzSLihodQEJ5oDn5zQSZc59xJZ5oKijfjlKo5Ggnj s8oDYKSfL6tx81A/9xT2AEH X-Received: by 2002:a05:6000:2407:b0:439:b3d2:3766 with SMTP id ffacd0b85a97d-43b6423fc13mr8053476f8f.19.1774033475555; Fri, 20 Mar 2026 12:04:35 -0700 (PDT) Received: from [192.168.1.122] (cpc159313-cmbg20-2-0-cust161.5-4.cable.virginm.net. [82.0.78.162]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b644bd923sm9802710f8f.12.2026.03.20.12.04.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Mar 2026 12:04:35 -0700 (PDT) Message-ID: <90a03d3c-def3-4e34-89a0-6e952d3b0d7a@gmail.com> Date: Fri, 20 Mar 2026 19:04:33 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: sfc: avoid format string warning To: Arnd Bergmann , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Jeff Garzik , Ben Hutchings Cc: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , Brett Creeley , Breno Leitao , Kees Cook , netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20260320151924.3474821-1-arnd@kernel.org> Content-Language: en-GB From: Edward Cree In-Reply-To: <20260320151924.3474821-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 20/03/2026 15:19, Arnd Bergmann wrote: > From: Arnd Bergmann > > Three sfc drivers contain the same *_fill_test() function that takes > a format string argument that gets passed down to snprintf(), producing > a warning with clang-22: > > drivers/net/ethernet/sfc/falcon/ethtool.c:227:60: error: diagnostic behavior may be improved by adding > the 'format(printf, 7, 8)' attribute to the declaration of 'ef4_fill_test' [-Werror,-Wmissing-format-attribute] > 210 | snprintf(test_str, sizeof(test_str), test_format, test_id); > | ^ > drivers/net/ethernet/sfc/falcon/ethtool.c:210:13: note: 'ef4_fill_test' declared here > > Rework these to take a varargs based test_format that allows better > type checking and avoids this warning. > > Fixes: 3273c2e8c66a ("[netdrvr] sfc: sfc: Add self-test support") > Signed-off-by: Arnd Bergmann I'm not convinced this is an improvement. The function takes *two* printf format strings (unit_format and test_format), and this only annotates and varargs-ifies one of them (and doesn't harden the unit_format, which has the considerably more worrying-looking "if it has a % in, assume it takes precisely one int argument"). So it may make things 'look' hardened enough to satisfy the compiler warning, but that just hides the unsafety and might sucker future developers into thinking "oh, the compiler knows about the format strings so I don't need to check it by hand". I'm not sure what a proper fix would look like — possibly a rewrite adding a separate efx_fill_test_perq() function for the cases with a nontrivial unit_format, baking in the knowledge that the format is always "foo%d" for some constant string foo and thus we don't actually need to pass in an arbitrary format string. > -static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data, > - int *test, const char *unit_format, int unit_id, > - const char *test_format, const char *test_id) > +static void __printf(7, 8) > +efx_fill_test(unsigned int test_index, u8 *strings, u64 *data, I don't like splitting the specifiers/return type from the function name like this. It's not Linux style[1]. (From a quick poke around the tree, there seems to be less consensus on where the __printf attribute goes — some put it on its own line before `static`, some would put it between `static` and `void`… sigh.) -Ed [1]: https://lore.kernel.org/all/1054519757.161606@palladium.transmeta.com/T/#u