From nobody Sat Feb 7 15:09:57 2026 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (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 9005D2253EE for ; Sun, 1 Feb 2026 18:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769969177; cv=none; b=Wl6N5ZVWl0v0VKwt5/dj7Lyt4alMUIeTCBHtT1Yd9Mn7Wz/K13Eax+QZFbzQbj1I9Ubzi8rP6uKhYExjR5CHEGZ7uDIXQ5QEulgyA9VnSz3H32nQ9UPOWj5DMatrs8q2cBlyZgZWwvAG20hFFYj6+coqboZZ7oFscmoazDyMoAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769969177; c=relaxed/simple; bh=QvYG1NXSzapY3iN4ReseN1zWtPiBu3A106cjFPaZZgM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bFQcbKxN6JccZWck9sIu417wWiO9L3Wx6oPakR4INp2xtdvsRE4TulAgBQxWjCqyFlwY1m3VCfErYD9HUfXMwvRJH2WCJzrr+Jq8TuXf/xuSZpsJ50XpKvbbBzIeQSvc5llrdDXDHtmuhfwQ27XlSGGzO8LhPzAWdtsCycq8hYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Ke5YHglO; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Ke5YHglO" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1769969163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DquVoHz0bHRbcPaOo1xT2MSMheeHJTE2vLWSd+7qSoU=; b=Ke5YHglOg5C/WDjMUBbXslPEyrWrm5KgiVEReLHCMQPGDH9MMXSDoDU7EnwknGuSKptG/v SMMpxk+PBceEF3yE7muACEK7i7eb+Qo3e72f+khFXccXLagO4LRg7K6wWWCKtzl5s2QJjt SgAUWl/KKtPbNxb2LZPgd4wi4cxJoas= From: Thorsten Blum To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: Thorsten Blum , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next] bpf: Replace snprintf("%s", ...) with strscpy() Date: Sun, 1 Feb 2026 19:04:46 +0100 Message-ID: <20260201180445.664056-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace snprintf("%s", ...) with the faster and more direct strscpy(). Signed-off-by: Thorsten Blum --- kernel/bpf/btf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 8959f3bc1e92..72fa0cb1a71b 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include =20 @@ -1210,8 +1211,7 @@ static const char *btf_show_name(struct btf_show *sho= w) =20 /* Even if we don't want type name info, we want parentheses etc */ if (show->flags & BTF_SHOW_NONAME) - snprintf(show->state.name, sizeof(show->state.name), "%s", - parens); + strscpy(show->state.name, parens); else snprintf(show->state.name, sizeof(show->state.name), "%s%s%s(%s%s%s%s%s%s)%s", @@ -6324,7 +6324,7 @@ static struct btf *btf_parse_base(struct btf_verifier= _env *env, const char *name btf->data_size =3D data_size; btf->kernel_btf =3D true; btf->named_start_id =3D 0; - snprintf(btf->name, sizeof(btf->name), "%s", name); + strscpy(btf->name, name); =20 err =3D btf_parse_hdr(env); if (err) @@ -6443,7 +6443,7 @@ static struct btf *btf_parse_module(const char *modul= e_name, const void *data, btf->start_str_off =3D base_btf->hdr.str_len; btf->kernel_btf =3D true; btf->named_start_id =3D 0; - snprintf(btf->name, sizeof(btf->name), "%s", module_name); + strscpy(btf->name, module_name); =20 btf->data =3D kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN); if (!btf->data) { --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4