From d3bdba381607364d0b3ef9e150fbaa107441cf51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 20 Mar 2019 13:43:35 +0100 Subject: [PATCH] test-fileio: avoid warning about ineffective comparison On arm64 with gcc-8.2.1-5.fc29.aarch64: ../src/test/test-fileio.c:645:29: warning: comparison is always false due to limited range of data type [-Wtype-limits] assert_se(c == EOF || safe_fgetc(f, &c) == 1); ^~ Casting c to int is not enough, gcc is able to figure out that the original type was unsigned and still warns. So let's just silence the warning like in test-sizeof.c. --- src/test/test-fileio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 2ddaabe7f89..3dd4287ff0f 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -629,6 +629,10 @@ static void test_tempfn(void) { static const char chars[] = "Aąę„”\n루\377"; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" + static void test_fgetc(void) { _cleanup_fclose_ FILE *f = NULL; char c; @@ -640,7 +644,7 @@ static void test_fgetc(void) { assert_se(safe_fgetc(f, &c) == 1); assert_se(c == chars[i]); - /* EOF is -1, and hence we can't push value 255 in this way */ + /* EOF is -1, and hence we can't push value 255 in this way if char is signed */ assert_se(ungetc(c, f) != EOF || c == EOF); assert_se(c == EOF || safe_fgetc(f, &c) == 1); assert_se(c == chars[i]); @@ -654,6 +658,8 @@ static void test_fgetc(void) { assert_se(safe_fgetc(f, &c) == 0); } +#pragma GCC diagnostic pop + static const char buffer[] = "Some test data\n" "루Non-ascii chars: ąę„”\n" -- 2.47.3