]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Removed redundant fd after close in bpf_prog_load_log_buf
authorZhu Jun <zhujun2@cmss.chinamobile.com>
Thu, 10 Oct 2024 05:57:37 +0000 (22:57 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 11 Oct 2024 02:15:02 +0000 (19:15 -0700)
Removed unnecessary `fd = -1` assignments after closing file descriptors.
because it will be assigned by the function bpf_prog_load().This improves
code readability and removes redundant operations.

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241010055737.4292-1-zhujun2@cmss.chinamobile.com
tools/testing/selftests/bpf/prog_tests/log_buf.c

index 27676a04d0b6924a44a3af5eb0fabda1370f7f64..169ce689b97c67ca342e8d2e3647d172b7182587 100644 (file)
@@ -169,7 +169,6 @@ static void bpf_prog_load_log_buf(void)
        ASSERT_GE(fd, 0, "good_fd1");
        if (fd >= 0)
                close(fd);
-       fd = -1;
 
        /* log_level == 2 should always fill log_buf, even for good prog */
        log_buf[0] = '\0';
@@ -180,7 +179,6 @@ static void bpf_prog_load_log_buf(void)
        ASSERT_GE(fd, 0, "good_fd2");
        if (fd >= 0)
                close(fd);
-       fd = -1;
 
        /* log_level == 0 should fill log_buf for bad prog */
        log_buf[0] = '\0';
@@ -191,7 +189,6 @@ static void bpf_prog_load_log_buf(void)
        ASSERT_LT(fd, 0, "bad_fd");
        if (fd >= 0)
                close(fd);
-       fd = -1;
 
        free(log_buf);
 }