Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/bpf: syscall_tp_user: Rename num_progs into nr_tests

The variable name num_progs causes confusion because that variable
really controls the number of rounds the test should be executed.

Rename num_progs into nr_tests for the sake of clarity.

Signed-off-by: Jinghao Jia <jinghao@linux.ibm.com>
Signed-off-by: Ruowen Qin <ruowenq2@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Link: https://lore.kernel.org/r/20230917214220.637721-3-jinghao7@illinois.edu
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Jinghao Jia and committed by
Alexei Starovoitov
0ee352fe cf67d28d

+12 -12
+12 -12
samples/bpf/syscall_tp_user.c
··· 17 17 18 18 static void usage(const char *cmd) 19 19 { 20 - printf("USAGE: %s [-i num_progs] [-h]\n", cmd); 21 - printf(" -i num_progs # number of progs of the test\n"); 22 - printf(" -h # help\n"); 20 + printf("USAGE: %s [-i nr_tests] [-h]\n", cmd); 21 + printf(" -i nr_tests # rounds of test to run\n"); 22 + printf(" -h # help\n"); 23 23 } 24 24 25 25 static void verify_map(int map_id) ··· 45 45 } 46 46 } 47 47 48 - static int test(char *filename, int num_progs) 48 + static int test(char *filename, int nr_tests) 49 49 { 50 - int map0_fds[num_progs], map1_fds[num_progs], fd, i, j = 0; 51 - struct bpf_link *links[num_progs * 4]; 52 - struct bpf_object *objs[num_progs]; 50 + int map0_fds[nr_tests], map1_fds[nr_tests], fd, i, j = 0; 51 + struct bpf_link *links[nr_tests * 4]; 52 + struct bpf_object *objs[nr_tests]; 53 53 struct bpf_program *prog; 54 54 55 - for (i = 0; i < num_progs; i++) { 55 + for (i = 0; i < nr_tests; i++) { 56 56 objs[i] = bpf_object__open_file(filename, NULL); 57 57 if (libbpf_get_error(objs[i])) { 58 58 fprintf(stderr, "opening BPF object file failed\n"); ··· 101 101 close(fd); 102 102 103 103 /* verify the map */ 104 - for (i = 0; i < num_progs; i++) { 104 + for (i = 0; i < nr_tests; i++) { 105 105 verify_map(map0_fds[i]); 106 106 verify_map(map1_fds[i]); 107 107 } ··· 117 117 118 118 int main(int argc, char **argv) 119 119 { 120 - int opt, num_progs = 1; 120 + int opt, nr_tests = 1; 121 121 char filename[256]; 122 122 123 123 while ((opt = getopt(argc, argv, "i:h")) != -1) { 124 124 switch (opt) { 125 125 case 'i': 126 - num_progs = atoi(optarg); 126 + nr_tests = atoi(optarg); 127 127 break; 128 128 case 'h': 129 129 default: ··· 134 134 135 135 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); 136 136 137 - return test(filename, num_progs); 137 + return test(filename, nr_tests); 138 138 }