Skip to content

Commit 0515089

Browse files
johnhubbardhtejun
authored andcommitted
selftests/cgroup: fix clang warnings: uninitialized fd variable
First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via: make LLVM=1 -C tools/testing/selftests ...clang warns about fd being used uninitialized, in test_memcg_reclaim()'s error handling path. Fix this by initializing fd to -1. [1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/ Signed-off-by: John Hubbard <[email protected]> Reviewed-by: Roman Gushchin <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 1da2363 commit 0515089

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/testing/selftests/cgroup/test_memcontrol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,9 @@ static bool reclaim_until(const char *memcg, long goal)
716716
*/
717717
static int test_memcg_reclaim(const char *root)
718718
{
719-
int ret = KSFT_FAIL, fd, retries;
719+
int ret = KSFT_FAIL;
720+
int fd = -1;
721+
int retries;
720722
char *memcg;
721723
long current, expected_usage;
722724

0 commit comments

Comments
 (0)