linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c
@ 2025-04-28 13:19 Nysal Jan K.A.
  2025-04-28 13:19 ` [PATCH 2/2] selftests/mm: Fix a build failure on powerpc Nysal Jan K.A.
  2025-04-28 16:47 ` [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c Venkat Rao Bagalkote
  0 siblings, 2 replies; 5+ messages in thread
From: Nysal Jan K.A. @ 2025-04-28 13:19 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan
  Cc: Madhavan Srinivasan, Michael Ellerman, Segher Boessenkool,
	linuxppc-dev, Nysal Jan K.A.,
	Kevin Brodsky, linux-mm, linux-kselftest, linux-kernel

From: Madhavan Srinivasan <maddy@linux.ibm.com>

Commit 50910acd6f615 ("selftests/mm: use sys_pkey helpers consistently")
added a pkey_util.c to refactor some of the protection_keys functions accessible
by other tests. But this broken the build in powerpc in two ways,

pkey-powerpc.h: In function ‘arch_is_powervm’:
pkey-powerpc.h:73:21: error: storage size of ‘buf’ isn’t known
   73 |         struct stat buf;
      |                     ^~~
pkey-powerpc.h:75:14: error: implicit declaration of function ‘stat’; did you mean ‘strcat’? [-Wimplicit-function-declaration]
   75 |         if ((stat("/sys/firmware/devicetree/base/ibm,partition-name", &buf) == 0) &&
      |              ^~~~
      |              strcat

Since pkey_util.c includes pkeys-helper.h, which in turn includes pkeys-powerpc.h,
stat.h including is missing for "struct stat". This is fixed by adding "sys/stat.h"
in pkeys-powerpc.h

Secondly,

pkey-powerpc.h:55:18: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘u64’ {aka ‘long unsigned int’} [-Wformat=]
   55 |         dprintf4("%s() changing %016llx to %016llx\n",
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                          __func__, __read_pkey_reg(), pkey_reg);
      |                                    ~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    u64 {aka long unsigned int}
pkey-helpers.h:63:32: note: in definition of macro ‘dprintf_level’
   63 |                 sigsafe_printf(args);           \
      |                                ^~~~

These format specifier related warning are removed by adding
"__SANE_USERSPACE_TYPES__" to pkeys_utils.c.

Fixes: 50910acd6f615 ("selftests/mm: use sys_pkey helpers consistently")
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Nysal Jan K.A. <nysal@linux.ibm.com>
---
 tools/testing/selftests/mm/pkey-powerpc.h | 2 ++
 tools/testing/selftests/mm/pkey_util.c    | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tools/testing/selftests/mm/pkey-powerpc.h b/tools/testing/selftests/mm/pkey-powerpc.h
index 1bad310d282a..d8ec906b8120 100644
--- a/tools/testing/selftests/mm/pkey-powerpc.h
+++ b/tools/testing/selftests/mm/pkey-powerpc.h
@@ -3,6 +3,8 @@
 #ifndef _PKEYS_POWERPC_H
 #define _PKEYS_POWERPC_H
 
+#include <sys/stat.h>
+
 #ifndef SYS_pkey_alloc
 # define SYS_pkey_alloc		384
 # define SYS_pkey_free		385
diff --git a/tools/testing/selftests/mm/pkey_util.c b/tools/testing/selftests/mm/pkey_util.c
index ca4ad0d44ab2..255b332f7a08 100644
--- a/tools/testing/selftests/mm/pkey_util.c
+++ b/tools/testing/selftests/mm/pkey_util.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#define __SANE_USERSPACE_TYPES__
 #include <sys/syscall.h>
 #include <unistd.h>
 
-- 
2.47.0



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

end of thread, other threads:[~2025-04-28 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-28 13:19 [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c Nysal Jan K.A.
2025-04-28 13:19 ` [PATCH 2/2] selftests/mm: Fix a build failure on powerpc Nysal Jan K.A.
2025-04-28 16:49   ` Venkat Rao Bagalkote
2025-04-28 17:13   ` Donet Tom
2025-04-28 16:47 ` [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c Venkat Rao Bagalkote

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