Article View: linux.kernel.netdev
Article #17998[PATCH] net: bridge: avoid redundant strlen() in show_backup_port()
From: Dmitry Antipov
Date: Tue, 17 Nov 2026 16:51
Date: Tue, 17 Nov 2026 16:51
31 lines
9008 bytes
9008 bytes
In store_backup_port(), prefer strchrnul() over strchr() to
avoid redundant call to strlen().
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
net/bridge/br_sysfs_if.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 621d62a063d9..03205b3f465f 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -231,12 +231,12 @@ static ssize_t show_backup_port(struct net_bridge_port *p, char *buf)
static int store_backup_port(struct net_bridge_port *p, char *buf)
{
struct net_device *backup_dev = NULL;
- char *nl = strchr(buf, '\n');
+ char *nl = strchrnul(buf, '\n');
- if (nl)
+ if (*nl != '\0')
*nl = '\0';
- if (strlen(buf) > 0) {
+ if (nl - buf > 0) {
backup_dev = __dev_get_by_name(dev_net(p->dev), buf);
if (!backup_dev)
return -ENOENT;
--
2.56.1
Technical Details
Message-ID:
<20261117165106.635733-1-dmantipov@yandex.ru>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365457-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365457-linux-kernel-netdev=dewy.ru From: dmantipov@yandex.ru (Dmitry Antipov) Newsgroups: linux.kernel.netdev Subject: [PATCH] net: bridge: avoid redundant strlen() in show_backup_port() Date: Tue, 17 Nov 2026 19:51:06 +0300 Organization: Usenet Network Message-ID: <20261117165106.635733-1-dmantipov@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2381063"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:WwmTLYafAI86/QivOVgZTaniAhk= sha256:ihuTGkxh1MPhOegwI5AdHD4/vxLQDV+o0BFO0KBun30= sha1:bMbxzVSFUdSbIZqbzJaxrbcCqRw= sha256:e1/eGdv1Iakl6UsLwDwalxg/Kbt+yTs8W4X7Rf7i6Lg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E71E2115003; Tue, 17 Nov 2026 19:51:37 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.047 X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=yandex.ru X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7ZyIKTSEvSXr; Tue, 17 Nov 2026 19:51:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-365457-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=yandex.ru X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id D97E5114FFE; Tue, 17 Nov 2026 19:51:26 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id BFB4F37BAB; Tue, 17 Nov 2026 16:51:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794934285; b=0tAL0DONi6mpxal2EY8zDF1PA3kPkaZvh9rn84kVQzl1Hgd+dGyTFrArQbYJ5ixVaFFC NL0DvBqTl708SRFhIpmQPaALCsxv4atiR3yyafWqmZC22IU8robWuHCsfAy8W1KnbCU7N /Pyg1rjuztkgP0eBxD4tFYlty8BRLU26YaMT3T/AJtARxVEXWiMRoM2VGXwQ8XjxVwgAZ WNjwRCy+TjYrAq/kqzgSU7WIbKkAycSSM7Hjvd4KMHjzVUBgFexKGPHkwPepfu8X+a8vZ jX1ynyYb1RmpLUqWP1CitflVCeyBEEx4qCBUkWFQLW4vzrjjpUpeJcmevKHn0Tk1Ayw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794934285; h=X-Original-To:Received:DMARC-Filter:Received:Received:X-Yandex-Fwd: DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=xnTlG3RhB5eZYXoKfh+lrOl3/6yxxp2X5UnqYVp1GAI=; b=ZUNUtcvAlHyn/7bGFQygsUGeIilPoO0pZekvYUoUXCz6g26tSB4smfIIJkBvJ+0+8Cy4 uzpwRnNXG5BNqCZN+hT7b8m0oUvImQC+CkKn1QgDuV6A7/Jgk3yNbk0nYkOAWFWienlkp vuUADLUuITFY/IwKow3KQTY6qMD0Pw2RVfQo8HDPLtT14hHc8yTsVOnuKZwF4u2p48Rii bu6wOW65b2drTMD2Ttc/CdN35KtiDFNf5sDOs4sHWu14msBfEHLEcZIGdudEuMiYVDDGR DItiSSY5/smHMGvebHJzxQbKwZDRYuEndKC4Zr82q7VPQJmlzIGz6oSNUkBgpyOIc0Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=fu1HXOF+; dmarc=pass header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8122606A339; Tue, 17 Nov 2026 16:51:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=fu1HXOF+ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.250.124.96 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794934284; b=wKx3HSHj+gXURwPux5LzhkvwqMQ9zmTv96dY5xmPHVJdeX2TkPkpdCLFBi6s5RGd3Iin J1RbTtxzVzPtbRA11FQKNJgrmIUZsgLcpQlLW3u2/V0CaTYkgAZwJBcy0asBBhNZqcs4W ZktbpiI68JF04ZmOvoZwP4ENvopHDhWPiclMYkVNJghqAlnVsZ7dCAobRAZYVJ5S16Q22 L0/YsSiQTPMHPpu7dOgHxhJJ+1p1P8fkTY6g9VYC+piC/p2N/hKQbmEFf20vCFfPzfEFh QPV73lxkMtY5hAx31iyakXYrbQv8Hldfs9PRI/11EOfXGXo9Rvhqnk8Uk/1VMJdKprA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794934284; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=xnTlG3RhB5eZYXoKfh+lrOl3/6yxxp2X5UnqYVp1GAI=; b=4XVumJF8kLxCqBbLazWVWNS76bSTf0zSu4j7o7lB7o9n1fceN0onlmSFlhKNPODVFbur PMppfzENowbRVDO/1WdKiDXVnpQPRCUAszw0fKUWzSammdOy73Snxh4zCEQSu61BqAZ96 Gcjfw9E22KUgvW4LUAlwvyMXeV6YYVZWFqE68BLE76ycCqvHek4BPT8jd+Bb8aqpzP9Ux f4HcWequ7+u1Mv8/maPrYs7LBqBm5sw050/lORSmEEjhFp8X1iwNeYeYT+LHeRknmIv+w 9/0usUGRRiFe4jojnV6KQzoLFOIYwD/9NCApral/uWzo5aiDCWkBgPnCXIM9NgefYDg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=fu1HXOF+; arc=none smtp.remote-ip=51.250.124.96 X-Received: from forward100a.mail.yandex.net (forward100a.mail.yandex.net [51.250.124.96]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CFD606A33D for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 16:51:21 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7CFD606A33D X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru X-Received: from mail-nwsmtp-smtp-production-main-73 (mail-nwsmtp-smtp-production-main-73.yp-c.yandex.net) by forward100a.mail.yandex.net (postfix) with ESMTPS id 9AFA4C03DB; Tue, 17 Nov 2026 19:51:12 +0300 (MSK) X-Received: by mail-nwsmtp-smtp-production-main-73 with ESMTPSA id 8pcmEQ0mua60-7s8HV7bS; Tue, 17 Nov 2026 19:51:11 +0300 X-Yandex-Fwd: 1 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1794934271; bh=xnTlG3RhB5eZYXoKfh+lrOl3/6yxxp2X5UnqYVp1GAI=; h=Message-ID:Date:Cc:Subject:To:From; b=fu1HXOF+WB8tkBLAnYa//UwM5+WLJ7+kyPMhRJDTBmzbWDFWRa318TfGZYc9Pwvor +VpIa2E8pqV169upH6lcMNGupesUsDe5SiPx155LR4Uk4NNPtjzLhxN4vaqy8Y6V8m g38YFsyJZYT7jizbyBH4+J/joWfh5XP/txKSJCQ8= X-Authentication-Results: mail-nwsmtp-smtp-production-main-73; dkim=pass header.i=@yandex.ru X-Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, Dmitry Antipov <dmantipov@yandex.ru> X-Mailer: git-send-email 2.56.1 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list