mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] selftests/memfd: fix compilation warnings
@ 2026-05-24 19:35 Eva Kurchatova
  2026-05-24 19:35 ` [PATCH 1/2] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
  2026-05-24 19:35 ` [PATCH 2/2] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
  0 siblings, 2 replies; 3+ messages in thread
From: Eva Kurchatova @ 2026-05-24 19:35 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, linux-kernel, aris, akpm, eva.kurchatova, khorenko

This patchset fixes warnings about unused but initialized variables,
and unused dummy buffer passed to pwrite() syscall in the tests.

Konstantin Khorenko (2):
  selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test
  selftests/memfd: remove unused variable 'sig' in fuse_test

 tools/testing/selftests/memfd/fuse_test.c  | 2 +-
 tools/testing/selftests/memfd/memfd_test.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test
  2026-05-24 19:35 [PATCH 0/2] selftests/memfd: fix compilation warnings Eva Kurchatova
@ 2026-05-24 19:35 ` Eva Kurchatova
  2026-05-24 19:35 ` [PATCH 2/2] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
  1 sibling, 0 replies; 3+ messages in thread
From: Eva Kurchatova @ 2026-05-24 19:35 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, linux-kernel, aris, akpm, eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  memfd_test.c: In function 'mfd_fail_grow_write.part.0':
  memfd_test.c:685:13: warning: '<unknown>' may be used uninitialized
  [-Wmaybe-uninitialized]
    685 |         l = pwrite(fd, buf, mfd_def_size * 8, 0);
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pwrite() is declared with attribute 'access (read_only, 2, 3)', so GCC
knows it reads from the buffer. malloc() returns uninitialized memory,
hence the warning. Use calloc() to zero-initialize the buffer. The
actual contents don't matter here since the test verifies that pwrite()
fails on a sealed memfd.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 2ca07ea7202a..cdab3a837624 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -688,9 +688,9 @@ static void mfd_assert_grow_write(int fd)
 	if (hugetlbfs_test)
 		return;
 
-	buf = malloc(mfd_def_size * 8);
+	buf = calloc(1, mfd_def_size * 8);
 	if (!buf) {
-		printf("malloc(%zu) failed: %m\n", mfd_def_size * 8);
+		printf("calloc(1, %zu) failed: %m\n", mfd_def_size * 8);
 		abort();
 	}
 
-- 
2.54.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] selftests/memfd: remove unused variable 'sig' in fuse_test
  2026-05-24 19:35 [PATCH 0/2] selftests/memfd: fix compilation warnings Eva Kurchatova
  2026-05-24 19:35 ` [PATCH 1/2] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
@ 2026-05-24 19:35 ` Eva Kurchatova
  1 sibling, 0 replies; 3+ messages in thread
From: Eva Kurchatova @ 2026-05-24 19:35 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, linux-kernel, aris, akpm, eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  fuse_test.c: In function 'sealing_thread_fn':
  fuse_test.c:165:13: warning: unused variable 'sig' [-Wunused-variable]
    165 |         int sig, r;
        |             ^~~

Remove unused 'sig' to fix -Wunused-variable warning.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/memfd/fuse_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index dbc171a3806d..510056c1b0d0 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -162,7 +162,7 @@ static void *global_p = NULL;
 
 static int sealing_thread_fn(void *arg)
 {
-	int sig, r;
+	int r;
 
 	/*
 	 * This thread first waits 200ms so any pending operation in the parent
-- 
2.54.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-24 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-24 19:35 [PATCH 0/2] selftests/memfd: fix compilation warnings Eva Kurchatova
2026-05-24 19:35 ` [PATCH 1/2] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
2026-05-24 19:35 ` [PATCH 2/2] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®