From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 B46651F1315 for ; Sun, 1 Feb 2026 08:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769934559; cv=none; b=A55RJ9JAqA0nHndJGmXrPUynIKNS4Qhj4JLzS3A1sg1UG0ayAJoZ2jsCEX9/ojb0NYIjoRFgHfIItidt4AFe3LLq0n8dDUVbCBpWyzLed8rdUaZ7RLyj4NYgje5sBrjf2X/+9aZDTn2EcqhKbV+zZ+60di453rAv4PAdx+qpGSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769934559; c=relaxed/simple; bh=6JBUx5f0OtPOVTySvaqIgC/De4Hhkb8Gn7hMOdnqxxE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hhaP3x0kqxd8i5i/FeFwCB39B29JEconu49HUwSJQe68aMGryZ+VUOF7Ru6hgm90UdmWB0Ek/8yV/SCgp9ngsCW/8hRB9I5lKhRcurmcZaNDdYejYrX2W5rbwF5nGw0VD76Tew2Z5kIFmA9wt/PP5iCavrnNhA4Chb4MXJFqvvc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org; spf=none smtp.mailfrom=blackwall.org; dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.b=BlHIV2wE; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=blackwall.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.b="BlHIV2wE" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4806e0f6b69so24799345e9.3 for ; Sun, 01 Feb 2026 00:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall.org; s=google; t=1769934556; x=1770539356; 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=SeZOjfl31A9xEaccgdXksgXuAf1M1N9YkibI/QkCSYk=; b=BlHIV2wE69qSvBO7ViBVEHnlMep1pP7Ti3Sh9mA/qmdybbN+aFSt9oANhhPK2L889m ml8Juie4dMZXIrKrQgrKYIIkEC8GOaOnDlZauXB2TTzk5BrhAuwPKj1zobWtznNw57bY nT5E1apCmyrf+BEMSeiXOKMeHPljQa5OtxtMxLN6ZVMcjcpv+rpkvCHZTUtVf/XmUpaz zr0OX9tLw3PBhxC0TKZfS0aTiVNJTINa6GnpAWum63JEu70+NIIy8OvjoTS7kQFyZTpT z5J80zYdPYfoFijtbI+f80sMwEarTVhEljdpk0I2tqQiwcJNMaUZfgjOMpPOjm3mH1wK qF6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769934556; x=1770539356; 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=SeZOjfl31A9xEaccgdXksgXuAf1M1N9YkibI/QkCSYk=; b=h0rra1ig5kcy0VZp9c7gvu7f3HE2ENobmvuEtoqJMl9YpDxUA0oDP/avDCNBELTAta kC1BXTeyyqWx02N8dwxO26Wb2S83AJ9wyPZOHSy6xpKuor1xxJq6ppEG/YPFcgDR2pTf 2zcHb3cXp01uXoLHWStLguJd1l4qSOXimjyibMcikvxcLCLFohQLXp8Cdwvx8BDWjuKf YhkyjHlYkPa1MHTCxmvMIQ3YPoC6CtFywfDwlUezW1gkH3uih2IVF0Lvz8zTJZETs6o/ f13Rhu1OeV7kWJUVrhEL3n8U575xa+GL9XNONm6iodsyqWS+zuaEW3z0lBE7nQEJy96T x16w== X-Forwarded-Encrypted: i=1; AJvYcCWQSWvnS+J78OHVrkGbI2fzS+wSFMBnhls241pqePXqfIflLRmO+WlJGD8sDrT196U0IVK2sIxeN84aYcY=@vger.kernel.org X-Gm-Message-State: AOJu0YzlfxfwQQWyc8TsU4kkK6IF9+w8wD583s9y3Ij/EeBXSFwyiGfk QkWNEVMeJBJF5qpbE8K4eBaKjex5Pa4FrbsGBJMjXWJsfzsmx7r8EalPuA+PNnaR+Ag= X-Gm-Gg: AZuq6aKvZmcCpzBeF5iz4d3DgtE9NWUbtTU0vIKnx74M8qBs9XtbIwZnpoeDHG9fncH O8yQKELFQ1a3EONDnxXDl1mxPQwNFpChGHkfTZvl4JOImITZrRbVWFPQfgMv8begV18o0ug2sGU He5FobBHpQRzzzMf3QkXCCMAuGt/iSfbM4oSCoM5blSUwnzOhiWz+7U32whn3M7Zr0DbpuNUNeo RIkIpXVTYxbi0HNoIrLM+Ie/+nlUe/JZ2qQ562WqFarkCbOaVFsW6N4zE5HnYbtW9EVFXdocfBG 4hJ+7nygDjr/CZ4DSRO7bHCN5jTTKS3lXgDc1gtMX6wXOH678UYvv+TGJSbEBU+Z7D6xIo4NhR6 /t7LmsAs7mxiV1oA+6fWN0XOpTwLKgHPSmGKjZAqT/0qga0f/++LuTBAZ3rpxjADikMU2HptJ59 4MCBSxF9LfOGshswUsz3AtDjjEnFbw/Ts+EBUEt83L7Q== X-Received: by 2002:a05:600c:5288:b0:480:4d37:e742 with SMTP id 5b1f17b1804b1-482db451e66mr97897665e9.10.1769934555855; Sun, 01 Feb 2026 00:29:15 -0800 (PST) Received: from [192.168.0.161] (78-154-15-142.ip.btc-net.bg. [78.154.15.142]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e1322dc7sm35418959f8f.37.2026.02.01.00.29.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Feb 2026 00:29:15 -0800 (PST) Message-ID: <076bd8aa-e06c-4b0f-a659-d35de0319b55@blackwall.org> Date: Sun, 1 Feb 2026 10:29:14 +0200 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-next] net: bridge: use sysfs_emit instead of sprintf To: David Corvaglia , idosch@nvidia.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <0100019c14f90490-950ddd9b-1897-4111-bddd-0d4b8abf380a-000000@email.amazonses.com> Content-Language: en-US From: Nikolay Aleksandrov In-Reply-To: <0100019c14f90490-950ddd9b-1897-4111-bddd-0d4b8abf380a-000000@email.amazonses.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 31/01/2026 18:53, David Corvaglia wrote: > Replace sprintf with sysfs_emit in sysfs show() methods as outlined in > Documentation/filesystems/sysfs.rst. sysfs_emit is preferred to sprintf > in sysfs show() methods as it is safer with buffer handling. > > Signed-off-by: David Corvaglia > --- > This is my first patch to the kernel! I've been able to build and boot > with the patch. I also tested the sysfs reads and they seem to be > correct. Any feedback is appreciated. > > net/bridge/br_stp_if.c | 2 +- > net/bridge/br_sysfs_br.c | 84 ++++++++++++++++++++-------------------- > net/bridge/br_sysfs_if.c | 32 +++++++-------- > 3 files changed, 59 insertions(+), 59 deletions(-) > Hi, IIUC it is safer because it takes into account the provided buffer's size (PAGE_SIZE). I'm saying it for the curious as I only found in Documentation/filesystems/sysfs.rst: "- New implementations of show() methods should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space." Which does say "new implementations", also most of these are numbers and cannot really fill the provided buffer, there is one instance of a string but it is an interface name, so that is limited as well. That being said, I'm ok with switching to sysfs_emit() and the patch looks good to me so: Acked-by: Nikolay Aleksandrov Thanks, Nik