Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Removed redundant fd after close in bpf_prog_load_log_buf

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

authored by

Zhu Jun and committed by
Andrii Nakryiko
ba4fb3b3 f3ef5317

-3
-3
tools/testing/selftests/bpf/prog_tests/log_buf.c
··· 169 169 ASSERT_GE(fd, 0, "good_fd1"); 170 170 if (fd >= 0) 171 171 close(fd); 172 - fd = -1; 173 172 174 173 /* log_level == 2 should always fill log_buf, even for good prog */ 175 174 log_buf[0] = '\0'; ··· 179 180 ASSERT_GE(fd, 0, "good_fd2"); 180 181 if (fd >= 0) 181 182 close(fd); 182 - fd = -1; 183 183 184 184 /* log_level == 0 should fill log_buf for bad prog */ 185 185 log_buf[0] = '\0'; ··· 189 191 ASSERT_LT(fd, 0, "bad_fd"); 190 192 if (fd >= 0) 191 193 close(fd); 192 - fd = -1; 193 194 194 195 free(log_buf); 195 196 }