Actually 'license' and 'insns' are const pointer. Before this patch
using 'bpf_load_program(... "GPL", ...)' triggers a warning, which is
unnecessary.

This patch makes these two arguments const pointers.

Signed-off-by: Wang Nan <wangn...@huawei.com>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/lib/bpf/bpf.c | 8 ++++----
 tools/lib/bpf/bpf.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 1f91cc9..88e6a46 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -55,8 +55,8 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size,
        return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
 }
 
-int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
-                    size_t insns_cnt, char *license,
+int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+                    size_t insns_cnt, const char *license,
                     u32 kern_version, char *log_buf, size_t log_buf_sz)
 {
        int fd;
@@ -65,8 +65,8 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn 
*insns,
        bzero(&attr, sizeof(attr));
        attr.prog_type = type;
        attr.insn_cnt = (__u32)insns_cnt;
-       attr.insns = ptr_to_u64(insns);
-       attr.license = ptr_to_u64(license);
+       attr.insns = ptr_to_u64((void *)insns);
+       attr.license = ptr_to_u64((void *)license);
        attr.log_buf = ptr_to_u64(NULL);
        attr.log_size = 0;
        attr.log_level = 0;
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index a764655..00cfeae 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -15,8 +15,8 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size, 
int value_size,
 
 /* Recommend log buffer size */
 #define BPF_LOG_BUF_SIZE 65536
-int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
-                    size_t insns_cnt, char *license,
+int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+                    size_t insns_cnt, const char *license,
                     u32 kern_version, char *log_buf,
                     size_t log_buf_sz);
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to