Skip to content

Commit d95d76a

Browse files
tobluxAlexei Starovoitov
authored andcommitted
bpf: Replace snprintf("%s") with strscpy
Replace snprintf("%s") with the faster and more direct strscpy(). Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20260201215247.677121-2-thorsten.blum@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 6b95cc5 commit d95d76a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

kernel/bpf/btf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/perf_event.h>
2626
#include <linux/bsearch.h>
2727
#include <linux/kobject.h>
28+
#include <linux/string.h>
2829
#include <linux/sysfs.h>
2930
#include <linux/overflow.h>
3031

@@ -6324,7 +6325,7 @@ static struct btf *btf_parse_base(struct btf_verifier_env *env, const char *name
63246325
btf->data_size = data_size;
63256326
btf->kernel_btf = true;
63266327
btf->named_start_id = 0;
6327-
snprintf(btf->name, sizeof(btf->name), "%s", name);
6328+
strscpy(btf->name, name);
63286329

63296330
err = btf_parse_hdr(env);
63306331
if (err)
@@ -6443,7 +6444,7 @@ static struct btf *btf_parse_module(const char *module_name, const void *data,
64436444
btf->start_str_off = base_btf->hdr.str_len;
64446445
btf->kernel_btf = true;
64456446
btf->named_start_id = 0;
6446-
snprintf(btf->name, sizeof(btf->name), "%s", module_name);
6447+
strscpy(btf->name, module_name);
64476448

64486449
btf->data = kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN);
64496450
if (!btf->data) {

0 commit comments

Comments
 (0)