mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
bpftool: Check argc first before "file" in do_batch()
If the parameters for batch are more than 2, check argc first can return immediately, no need to use is_prefix() to check "file" with a little overhead and then check argc, it is better to check "file" only when the parameters for batch are 2. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Acked-by: Stanislav Fomichev <sdf@google.com> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/r/1668517207-11822-1-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
e0eb60829a
commit
df9c41e9db
1 changed files with 3 additions and 3 deletions
|
@ -337,12 +337,12 @@ static int do_batch(int argc, char **argv)
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
p_err("too few parameters for batch");
|
p_err("too few parameters for batch");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (!is_prefix(*argv, "file")) {
|
|
||||||
p_err("expected 'file', got: %s", *argv);
|
|
||||||
return -1;
|
|
||||||
} else if (argc > 2) {
|
} else if (argc > 2) {
|
||||||
p_err("too many parameters for batch");
|
p_err("too many parameters for batch");
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (!is_prefix(*argv, "file")) {
|
||||||
|
p_err("expected 'file', got: %s", *argv);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue