diff mbox series

[COMMITTED,v2] Don't use nested function in test-ffs

Message ID 20201112092905.2221021-1-siddhesh@sourceware.org
State Committed
Headers show
Series [COMMITTED,v2] Don't use nested function in test-ffs | expand

Commit Message

Siddhesh Poyarekar Nov. 12, 2020, 9:29 a.m. UTC
This is what I committed based on your suggestion Florian.

Thanks,
Siddhesh



There is no real need to use a nested function in that test, so break
it out so that it can build with clang too.
---
 string/test-ffs.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/string/test-ffs.c b/string/test-ffs.c
index 0df488fa2b..af03df90a1 100644
--- a/string/test-ffs.c
+++ b/string/test-ffs.c
@@ -20,28 +20,25 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <support/check.h>
+
+void try (const char *name, long long int param, int value, int expected)
+{
+  if (value != expected)
+    {
+      printf ("%s(%#llx) expected %d got %d\n",
+	      name, param, expected, value);
+      support_record_failure ();
+    }
+  else
+    printf ("%s(%#llx) as expected %d\n", name, param, value);
+}
 
 int
 do_test (void)
 {
-  int failures = 0;
   int i;
 
-  auto void try (const char *name, long long int param, int value,
-		 int expected);
-
-  void try (const char *name, long long int param, int value, int expected)
-    {
-      if (value != expected)
-	{
-	  printf ("%s(%#llx) expected %d got %d\n",
-		  name, param, expected, value);
-	  ++failures;
-	}
-      else
-	printf ("%s(%#llx) as expected %d\n", name, param, value);
-    }
-
 #define TEST(fct, type) \
   try (#fct, 0, fct ((type) 0), 0);					      \
   for (i=0 ; i < 8 * sizeof (type); i++)				      \
@@ -54,12 +51,7 @@  do_test (void)
   TEST (ffsl, long int);
   TEST (ffsll, long long int);
 
-  if (failures)
-    printf ("Test FAILED!  %d failure%s.\n", failures, &"s"[failures == 1]);
-  else
-    puts ("Test succeeded.");
-
-  return failures;
+  return 0;
 }
 
 #include <support/test-driver.c>