samples/bpf: fix a couple of style issues in bpf_load
authorDaniel T. Lee <danieltimlee@gmail.com>
Thu, 23 May 2019 07:24:48 +0000 (16:24 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 28 May 2019 09:10:37 +0000 (11:10 +0200)
This commit fixes a few style problems in samples/bpf/bpf_load.c:

 - Magic string use of 'DEBUGFS'
 - Useless zero initialization of a global variable
 - Minor style fix with whitespace

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
samples/bpf/bpf_load.c

index eae7b635343d13182a4d458d3280464f6ffee4ca..1734ade04f7f4790235e1900566bcca63db5d5f5 100644 (file)
@@ -40,7 +40,7 @@ int prog_cnt;
 int prog_array_fd = -1;
 
 struct bpf_map_data map_data[MAX_MAPS];
-int map_data_count = 0;
+int map_data_count;
 
 static int populate_prog_array(const char *event, int prog_fd)
 {
@@ -65,7 +65,7 @@ static int write_kprobe_events(const char *val)
        else
                flags = O_WRONLY | O_APPEND;
 
-       fd = open("/sys/kernel/debug/tracing/kprobe_events", flags);
+       fd = open(DEBUGFS "kprobe_events", flags);
 
        ret = write(fd, val, strlen(val));
        close(fd);
@@ -490,8 +490,8 @@ static int load_elf_maps_section(struct bpf_map_data *maps, int maps_shndx,
 
                /* Verify no newer features were requested */
                if (validate_zero) {
-                       addr = (unsigned char*) def + map_sz_copy;
-                       end  = (unsigned char*) def + map_sz_elf;
+                       addr = (unsigned char *) def + map_sz_copy;
+                       end  = (unsigned char *) def + map_sz_elf;
                        for (; addr < end; addr++) {
                                if (*addr != 0) {
                                        free(sym);