Skip to content

Commit 3a4f0cc

Browse files
committed
selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn
Fix get_trans_hugepagesz() to check fscanf() return value to get rid of the following warning: lib/test_util.c: In function ‘get_trans_hugepagesz’: lib/test_util.c:138:2: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 138 | fscanf(f, "%ld", &size); | ^~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Shuah Khan <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 39a71f7 commit 3a4f0cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/testing/selftests/kvm/lib/test_util.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,16 @@ size_t get_trans_hugepagesz(void)
129129
{
130130
size_t size;
131131
FILE *f;
132+
int ret;
132133

133134
TEST_ASSERT(thp_configured(), "THP is not configured in host kernel");
134135

135136
f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
136137
TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size");
137138

138-
fscanf(f, "%ld", &size);
139+
ret = fscanf(f, "%ld", &size);
140+
ret = fscanf(f, "%ld", &size);
141+
TEST_ASSERT(ret < 1, "Error reading transparent_hugepage/hpage_pmd_size");
139142
fclose(f);
140143

141144
return size;

0 commit comments

Comments
 (0)