Re: [PATCH 07/12] selftests/mm: set -Wno-format-security to avoid uffd build warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/2/23 03:15, David Hildenbrand wrote:
...
Maybe the following will silence the warning by removing test_name
completely:


---
  tools/testing/selftests/mm/uffd-unit-tests.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 269c86768a02..15c76ce972be 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1149,7 +1149,6 @@ int main(int argc, char *argv[])
      uffd_test_case_t *test;
      mem_type_t *mem_type;
      uffd_test_args_t args;
-    char test_name[128];
      const char *errmsg;
      int has_uffd, opt;
      int i, j;
@@ -1192,10 +1191,8 @@ int main(int argc, char *argv[])
              mem_type = &mem_types[j];
              if (!(test->mem_targets & mem_type->mem_flag))
                  continue;
-            snprintf(test_name, sizeof(test_name),
-                 "%s on %s", test->name, mem_type->name);

-            uffd_test_start(test_name);
+            uffd_test_start("%s on %s", test->name, mem_type->name);
              if (!uffd_feature_supported(test)) {
                  uffd_test_skip("feature missing");
                  continue;


Yes, that does clean up one of the two warnings nicely. I'll do that
instead -Wno-format-security, thanks.

That still leaves another similar warning that fires for "errmsg".
However, that one is easily fixed because the associated macro turns out
to be unnecessary, because all callers pass a simple char* string,
without any format specifiers.

So just turning one macro into a C function fixes that, leaving us with
this (plus your fix from above):

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 269c86768a02..04d91f144d1c 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -109,12 +109,11 @@ static void uffd_test_pass(void)
 		ksft_inc_fail_cnt();		\
 	} while (0)

-#define  uffd_test_skip(...)  do {		\
-		printf("skipped [reason: ");	\
-		printf(__VA_ARGS__);		\
-		printf("]\n");			\
-		ksft_inc_xskip_cnt();		\
-	} while (0)
+static void uffd_test_skip(const char *message)
+{
+	printf("skipped [reason: %s]\n", message);
+	ksft_inc_xskip_cnt();
+}

I'll send that in a v2.


thanks,
--
John Hubbard
NVIDIA




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux