Set errno for bpf_object__find_map_by_name (#3712)
* Initial Commit * Initialize errno * Set errno for bpf_object__find_map_by_name * Added Doxygen comment
This commit is contained in:
Родитель
2448139787
Коммит
54632eb360
|
@ -247,6 +247,8 @@ bpf_object__close(struct bpf_object* object);
|
|||
* @param[in] name The name to look for.
|
||||
*
|
||||
* @returns The map found, or NULL if none.
|
||||
*
|
||||
* @exception ENOENT The map was not found.
|
||||
*/
|
||||
struct bpf_map*
|
||||
bpf_object__find_map_by_name(const struct bpf_object* obj, const char* name);
|
||||
|
|
|
@ -241,7 +241,7 @@ bpf_object__find_map_by_name(const struct bpf_object* obj, const char* name)
|
|||
return pos;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return (struct bpf_map*)libbpf_err_ptr(-ENOENT);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -480,9 +480,15 @@ TEST_CASE("libbpf program", "[libbpf]")
|
|||
struct bpf_program* program = bpf_object__find_program_by_name(object, "test_program_entry");
|
||||
REQUIRE(program != nullptr);
|
||||
|
||||
errno = 0;
|
||||
REQUIRE(bpf_object__find_program_by_name(object, "not_a_valid_name") == NULL);
|
||||
REQUIRE(errno == ENOENT);
|
||||
|
||||
// Testing invalid map name.
|
||||
errno = 0;
|
||||
REQUIRE(bpf_object__find_map_by_name(object, "not_a_valid_map") == NULL);
|
||||
REQUIRE(errno == ENOENT);
|
||||
|
||||
name = bpf_program__section_name(program);
|
||||
REQUIRE(strcmp(name, "sample_ext") == 0);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче