]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strutils: fix compiler error
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 6 Jan 2023 03:14:27 +0000 (03:14 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 6 Jan 2023 03:16:14 +0000 (03:16 +0000)
In file included from /usr/include/stdio.h:894,
                 from lib/strutils.c:8:
In function ‘printf’,
    inlined from ‘test_strutils_cstrcasecmp’ at lib/strutils.c:1324:2,
    inlined from ‘main’ at lib/strutils.c:1348:10:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:112:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  112 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

lib/strutils.c

index 830abc976db3dfd345ece3c57f5955f675daf051..6d863b85f65556c6fe31ef772a7b9abe2aaec0ac 100644 (file)
@@ -1322,6 +1322,9 @@ static int test_strutils_cstrcasecmp(int argc, char *argv[])
        a = argv[1];
        b = argv[2];
 
+       if (!a || !b)
+               return EXIT_FAILURE;
+
        printf("cmp    '%s' '%s' = %d\n", a, b, strcasecmp(a, b));
        printf("c_cmp  '%s' '%s' = %d\n", a, b, c_strcasecmp(a, b));
        printf("c_ncmp '%s' '%s' = %d\n", a, b, c_strncasecmp(a, b, strlen(a)));