summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorShuah Khan <skhan@linuxfoundation.org>2021-09-15 15:28:07 -0600
committerShuah Khan <skhan@linuxfoundation.org>2021-09-16 12:57:11 -0600
commit3a4f0cc693cd3d80e66a255f0bff0e2c0461eef1 (patch)
tree29c299f0eca5be159ec6a243dad0e79f7045d7ce /tools
parent39a71f712d8a13728febd8f3cb3f6db7e1fa7221 (diff)
downloadlinux-stable-3a4f0cc693cd3d80e66a255f0bff0e2c0461eef1.tar.gz
linux-stable-3a4f0cc693cd3d80e66a255f0bff0e2c0461eef1.tar.bz2
linux-stable-3a4f0cc693cd3d80e66a255f0bff0e2c0461eef1.zip
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 <skhan@linuxfoundation.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/kvm/lib/test_util.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
index af1031fed97f..938cd423643e 100644
--- a/tools/testing/selftests/kvm/lib/test_util.c
+++ b/tools/testing/selftests/kvm/lib/test_util.c
@@ -129,13 +129,16 @@ size_t get_trans_hugepagesz(void)
{
size_t size;
FILE *f;
+ int ret;
TEST_ASSERT(thp_configured(), "THP is not configured in host kernel");
f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size");
- fscanf(f, "%ld", &size);
+ ret = fscanf(f, "%ld", &size);
+ ret = fscanf(f, "%ld", &size);
+ TEST_ASSERT(ret < 1, "Error reading transparent_hugepage/hpage_pmd_size");
fclose(f);
return size;