diff options
author | KP Singh <kpsingh@kernel.org> | 2021-02-03 00:37:30 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-02-03 08:21:55 +0300 |
commit | 15075bb7228ae6422e9e79c27ea69cbd63a9d9dc (patch) | |
tree | 4795fef5727db1faa50629a7c602823091021d6f /tools/testing/selftests/bpf/prog_tests/test_local_storage.c | |
parent | 37086bfdc737ea6f66bf68dcf16757004d68e1e1 (diff) | |
download | linux-15075bb7228ae6422e9e79c27ea69cbd63a9d9dc.tar.xz |
selftests/bpf: Fix a compiler warning in local_storage test
Some compilers trigger a warning when tmp_dir_path is allocated
with a fixed size of 64-bytes and used in the following snprintf:
snprintf(tmp_exec_path, sizeof(tmp_exec_path), "%s/copy_of_rm",
tmp_dir_path);
warning: ‘/copy_of_rm’ directive output may be truncated writing 11
bytes into a region of size between 1 and 64 [-Wformat-truncation=]
This is because it assumes that tmp_dir_path can be a maximum of 64
bytes long and, therefore, the end-result can get truncated. Fix it by
not using a fixed size in the initialization of tmp_dir_path which
allows the compiler to track actual size of the array better.
Fixes: 2f94ac191846 ("bpf: Update local storage test to check handling of null ptrs")
Signed-off-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210202213730.1906931-1-kpsingh@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/test_local_storage.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/test_local_storage.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/test_local_storage.c b/tools/testing/selftests/bpf/prog_tests/test_local_storage.c index 3bfcf00c0a67..d2c16eaae367 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_local_storage.c +++ b/tools/testing/selftests/bpf/prog_tests/test_local_storage.c @@ -113,7 +113,7 @@ static bool check_syscall_operations(int map_fd, int obj_fd) void test_test_local_storage(void) { - char tmp_dir_path[64] = "/tmp/local_storageXXXXXX"; + char tmp_dir_path[] = "/tmp/local_storageXXXXXX"; int err, serv_sk = -1, task_fd = -1, rm_fd = -1; struct local_storage *skel = NULL; char tmp_exec_path[64]; |