Skip to content

Commit

Permalink
selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn
Browse files Browse the repository at this point in the history
[ Upstream commit 3a4f0cc ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
shuahkh authored and gregkh committed Oct 9, 2021
1 parent b664df7 commit b6d7e8c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/testing/selftests/kvm/lib/test_util.c
Expand Up @@ -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;
Expand Down

0 comments on commit b6d7e8c

Please sign in to comment.