[PATCH liburing v1 5/8] tests: Fix clang `-Wunreachable-code` warning

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

 



Clang says:

  fadvise.c:190:3: warning: code will never be executed [-Wunreachable-code]
                  fprintf(stderr, "Suspicious timings\n");
                  ^~~~~~~
  fadvise.c:189:6: note: silence by adding parentheses to mark code as \
  explicitly dead
          if (0 && bad > good) {
              ^
              /* DISABLES CODE */ ( )

  madvise.c:186:3: warning: code will never be executed [-Wunreachable-code]
                  fprintf(stderr, "Suspicious timings (%u > %u)\n", bad, good);
                  ^~~~~~~
  madvise.c:185:6: note: silence by adding parentheses to mark code as \
  explicitly dead
          if (0 && bad > good)
              ^
              /* DISABLES CODE */ ( )

Add parentheses to silence the warning.

Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx>
---
 test/fadvise.c | 2 +-
 test/madvise.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/fadvise.c b/test/fadvise.c
index 889f447..4f4d85f 100644
--- a/test/fadvise.c
+++ b/test/fadvise.c
@@ -179,21 +179,21 @@ int main(int argc, char *argv[])
 			goto err;
 		} else if (!ret)
 			good++;
 		else if (ret == 2)
 			bad++;
 		if (i >= MIN_LOOPS && !bad)
 			break;
 	}
 
 	/* too hard to reliably test, just ignore */
-	if (0 && bad > good) {
+	if ((0) && bad > good) {
 		fprintf(stderr, "Suspicious timings\n");
 		goto err;
 	}
 
 	if (fname != argv[1])
 		unlink(fname);
 	io_uring_queue_exit(&ring);
 	return T_EXIT_PASS;
 err:
 	if (fname != argv[1])
diff --git a/test/madvise.c b/test/madvise.c
index 8848143..7938ec4 100644
--- a/test/madvise.c
+++ b/test/madvise.c
@@ -175,21 +175,21 @@ int main(int argc, char *argv[])
 			goto err;
 		} else if (!ret)
 			good++;
 		else if (ret == 2)
 			bad++;
 		if (i >= MIN_LOOPS && !bad)
 			break;
 	}
 
 	/* too hard to reliably test, just ignore */
-	if (0 && bad > good)
+	if ((0) && bad > good)
 		fprintf(stderr, "Suspicious timings (%u > %u)\n", bad, good);
 	if (fname != argv[1])
 		unlink(fname);
 	io_uring_queue_exit(&ring);
 	return T_EXIT_PASS;
 err:
 	if (fname != argv[1])
 		unlink(fname);
 	return T_EXIT_FAIL;
 }
-- 
Ammar Faizi




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux