Commit 9875964b authored by Alexei Starovoitov's avatar Alexei Starovoitov

Merge branch 'libbpf-cleanup'

Andrii Nakryiko says:

====================
This patchset replaces bzero() with memset() and syncs if_link.h header
to suppress unsynchronized headers warning.
====================
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents fb405883 d9312064
...@@ -925,6 +925,7 @@ enum { ...@@ -925,6 +925,7 @@ enum {
enum { enum {
LINK_XSTATS_TYPE_UNSPEC, LINK_XSTATS_TYPE_UNSPEC,
LINK_XSTATS_TYPE_BRIDGE, LINK_XSTATS_TYPE_BRIDGE,
LINK_XSTATS_TYPE_BOND,
__LINK_XSTATS_TYPE_MAX __LINK_XSTATS_TYPE_MAX
}; };
#define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1) #define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <string.h>
#include <memory.h> #include <memory.h>
#include <unistd.h> #include <unistd.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -228,7 +228,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, ...@@ -228,7 +228,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
name_len = load_attr->name ? strlen(load_attr->name) : 0; name_len = load_attr->name ? strlen(load_attr->name) : 0;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.prog_type = load_attr->prog_type; attr.prog_type = load_attr->prog_type;
attr.expected_attach_type = load_attr->expected_attach_type; attr.expected_attach_type = load_attr->expected_attach_type;
attr.insn_cnt = (__u32)load_attr->insns_cnt; attr.insn_cnt = (__u32)load_attr->insns_cnt;
...@@ -340,7 +340,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, ...@@ -340,7 +340,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.prog_type = type; attr.prog_type = type;
attr.insn_cnt = (__u32)insns_cnt; attr.insn_cnt = (__u32)insns_cnt;
attr.insns = ptr_to_u64(insns); attr.insns = ptr_to_u64(insns);
...@@ -360,7 +360,7 @@ int bpf_map_update_elem(int fd, const void *key, const void *value, ...@@ -360,7 +360,7 @@ int bpf_map_update_elem(int fd, const void *key, const void *value,
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
attr.value = ptr_to_u64(value); attr.value = ptr_to_u64(value);
...@@ -373,7 +373,7 @@ int bpf_map_lookup_elem(int fd, const void *key, void *value) ...@@ -373,7 +373,7 @@ int bpf_map_lookup_elem(int fd, const void *key, void *value)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
attr.value = ptr_to_u64(value); attr.value = ptr_to_u64(value);
...@@ -385,7 +385,7 @@ int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags) ...@@ -385,7 +385,7 @@ int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
attr.value = ptr_to_u64(value); attr.value = ptr_to_u64(value);
...@@ -398,7 +398,7 @@ int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) ...@@ -398,7 +398,7 @@ int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
attr.value = ptr_to_u64(value); attr.value = ptr_to_u64(value);
...@@ -410,7 +410,7 @@ int bpf_map_delete_elem(int fd, const void *key) ...@@ -410,7 +410,7 @@ int bpf_map_delete_elem(int fd, const void *key)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
...@@ -421,7 +421,7 @@ int bpf_map_get_next_key(int fd, const void *key, void *next_key) ...@@ -421,7 +421,7 @@ int bpf_map_get_next_key(int fd, const void *key, void *next_key)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_fd = fd; attr.map_fd = fd;
attr.key = ptr_to_u64(key); attr.key = ptr_to_u64(key);
attr.next_key = ptr_to_u64(next_key); attr.next_key = ptr_to_u64(next_key);
...@@ -433,7 +433,7 @@ int bpf_obj_pin(int fd, const char *pathname) ...@@ -433,7 +433,7 @@ int bpf_obj_pin(int fd, const char *pathname)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.pathname = ptr_to_u64((void *)pathname); attr.pathname = ptr_to_u64((void *)pathname);
attr.bpf_fd = fd; attr.bpf_fd = fd;
...@@ -444,7 +444,7 @@ int bpf_obj_get(const char *pathname) ...@@ -444,7 +444,7 @@ int bpf_obj_get(const char *pathname)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.pathname = ptr_to_u64((void *)pathname); attr.pathname = ptr_to_u64((void *)pathname);
return sys_bpf(BPF_OBJ_GET, &attr, sizeof(attr)); return sys_bpf(BPF_OBJ_GET, &attr, sizeof(attr));
...@@ -455,7 +455,7 @@ int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type, ...@@ -455,7 +455,7 @@ int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type,
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.target_fd = target_fd; attr.target_fd = target_fd;
attr.attach_bpf_fd = prog_fd; attr.attach_bpf_fd = prog_fd;
attr.attach_type = type; attr.attach_type = type;
...@@ -468,7 +468,7 @@ int bpf_prog_detach(int target_fd, enum bpf_attach_type type) ...@@ -468,7 +468,7 @@ int bpf_prog_detach(int target_fd, enum bpf_attach_type type)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.target_fd = target_fd; attr.target_fd = target_fd;
attr.attach_type = type; attr.attach_type = type;
...@@ -479,7 +479,7 @@ int bpf_prog_detach2(int prog_fd, int target_fd, enum bpf_attach_type type) ...@@ -479,7 +479,7 @@ int bpf_prog_detach2(int prog_fd, int target_fd, enum bpf_attach_type type)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.target_fd = target_fd; attr.target_fd = target_fd;
attr.attach_bpf_fd = prog_fd; attr.attach_bpf_fd = prog_fd;
attr.attach_type = type; attr.attach_type = type;
...@@ -493,7 +493,7 @@ int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, ...@@ -493,7 +493,7 @@ int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags,
union bpf_attr attr; union bpf_attr attr;
int ret; int ret;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.query.target_fd = target_fd; attr.query.target_fd = target_fd;
attr.query.attach_type = type; attr.query.attach_type = type;
attr.query.query_flags = query_flags; attr.query.query_flags = query_flags;
...@@ -514,7 +514,7 @@ int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, ...@@ -514,7 +514,7 @@ int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size,
union bpf_attr attr; union bpf_attr attr;
int ret; int ret;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.test.prog_fd = prog_fd; attr.test.prog_fd = prog_fd;
attr.test.data_in = ptr_to_u64(data); attr.test.data_in = ptr_to_u64(data);
attr.test.data_out = ptr_to_u64(data_out); attr.test.data_out = ptr_to_u64(data_out);
...@@ -539,7 +539,7 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr) ...@@ -539,7 +539,7 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr)
if (!test_attr->data_out && test_attr->data_size_out > 0) if (!test_attr->data_out && test_attr->data_size_out > 0)
return -EINVAL; return -EINVAL;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.test.prog_fd = test_attr->prog_fd; attr.test.prog_fd = test_attr->prog_fd;
attr.test.data_in = ptr_to_u64(test_attr->data_in); attr.test.data_in = ptr_to_u64(test_attr->data_in);
attr.test.data_out = ptr_to_u64(test_attr->data_out); attr.test.data_out = ptr_to_u64(test_attr->data_out);
...@@ -559,7 +559,7 @@ int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id) ...@@ -559,7 +559,7 @@ int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id)
union bpf_attr attr; union bpf_attr attr;
int err; int err;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.start_id = start_id; attr.start_id = start_id;
err = sys_bpf(BPF_PROG_GET_NEXT_ID, &attr, sizeof(attr)); err = sys_bpf(BPF_PROG_GET_NEXT_ID, &attr, sizeof(attr));
...@@ -574,7 +574,7 @@ int bpf_map_get_next_id(__u32 start_id, __u32 *next_id) ...@@ -574,7 +574,7 @@ int bpf_map_get_next_id(__u32 start_id, __u32 *next_id)
union bpf_attr attr; union bpf_attr attr;
int err; int err;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.start_id = start_id; attr.start_id = start_id;
err = sys_bpf(BPF_MAP_GET_NEXT_ID, &attr, sizeof(attr)); err = sys_bpf(BPF_MAP_GET_NEXT_ID, &attr, sizeof(attr));
...@@ -588,7 +588,7 @@ int bpf_prog_get_fd_by_id(__u32 id) ...@@ -588,7 +588,7 @@ int bpf_prog_get_fd_by_id(__u32 id)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.prog_id = id; attr.prog_id = id;
return sys_bpf(BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr)); return sys_bpf(BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr));
...@@ -598,7 +598,7 @@ int bpf_map_get_fd_by_id(__u32 id) ...@@ -598,7 +598,7 @@ int bpf_map_get_fd_by_id(__u32 id)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.map_id = id; attr.map_id = id;
return sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, sizeof(attr)); return sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, sizeof(attr));
...@@ -608,7 +608,7 @@ int bpf_btf_get_fd_by_id(__u32 id) ...@@ -608,7 +608,7 @@ int bpf_btf_get_fd_by_id(__u32 id)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.btf_id = id; attr.btf_id = id;
return sys_bpf(BPF_BTF_GET_FD_BY_ID, &attr, sizeof(attr)); return sys_bpf(BPF_BTF_GET_FD_BY_ID, &attr, sizeof(attr));
...@@ -619,7 +619,7 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len) ...@@ -619,7 +619,7 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
union bpf_attr attr; union bpf_attr attr;
int err; int err;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.info.bpf_fd = prog_fd; attr.info.bpf_fd = prog_fd;
attr.info.info_len = *info_len; attr.info.info_len = *info_len;
attr.info.info = ptr_to_u64(info); attr.info.info = ptr_to_u64(info);
...@@ -635,7 +635,7 @@ int bpf_raw_tracepoint_open(const char *name, int prog_fd) ...@@ -635,7 +635,7 @@ int bpf_raw_tracepoint_open(const char *name, int prog_fd)
{ {
union bpf_attr attr; union bpf_attr attr;
bzero(&attr, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.raw_tracepoint.name = ptr_to_u64(name); attr.raw_tracepoint.name = ptr_to_u64(name);
attr.raw_tracepoint.prog_fd = prog_fd; attr.raw_tracepoint.prog_fd = prog_fd;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -484,7 +483,7 @@ int btf__get_from_id(__u32 id, struct btf **btf) ...@@ -484,7 +483,7 @@ int btf__get_from_id(__u32 id, struct btf **btf)
goto exit_free; goto exit_free;
} }
bzero(ptr, last_size); memset(ptr, 0, last_size);
btf_info.btf = ptr_to_u64(ptr); btf_info.btf = ptr_to_u64(ptr);
err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len); err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len);
...@@ -498,7 +497,7 @@ int btf__get_from_id(__u32 id, struct btf **btf) ...@@ -498,7 +497,7 @@ int btf__get_from_id(__u32 id, struct btf **btf)
goto exit_free; goto exit_free;
} }
ptr = temp_ptr; ptr = temp_ptr;
bzero(ptr, last_size); memset(ptr, 0, last_size);
btf_info.btf = ptr_to_u64(ptr); btf_info.btf = ptr_to_u64(ptr);
err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len); err = bpf_obj_get_info_by_fd(btf_fd, &btf_info, &len);
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <libgen.h> #include <libgen.h>
#include <inttypes.h> #include <inttypes.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
...@@ -308,7 +307,7 @@ bpf_program__init(void *data, size_t size, char *section_name, int idx, ...@@ -308,7 +307,7 @@ bpf_program__init(void *data, size_t size, char *section_name, int idx,
return -EINVAL; return -EINVAL;
} }
bzero(prog, sizeof(*prog)); memset(prog, 0, sizeof(*prog));
prog->section_name = strdup(section_name); prog->section_name = strdup(section_name);
if (!prog->section_name) { if (!prog->section_name) {
...@@ -1577,7 +1576,7 @@ bpf_program__load(struct bpf_program *prog, ...@@ -1577,7 +1576,7 @@ bpf_program__load(struct bpf_program *prog,
struct bpf_prog_prep_result result; struct bpf_prog_prep_result result;
bpf_program_prep_t preprocessor = prog->preprocessor; bpf_program_prep_t preprocessor = prog->preprocessor;
bzero(&result, sizeof(result)); memset(&result, 0, sizeof(result));
err = preprocessor(prog, i, prog->insns, err = preprocessor(prog, i, prog->insns,
prog->insns_cnt, &result); prog->insns_cnt, &result);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment