[PATCH libaio 17/28] harness: Use destination strncpy() expression for sizeof() argument
authorGuillem Jover <guillem@hadrons.org>
Sat, 20 Jul 2019 19:20:58 +0000 (21:20 +0200)
committerGuillem Jover <guillem@debian.org>
Thu, 11 Nov 2021 03:56:01 +0000 (03:56 +0000)
Even though this is the same size, as the sizeof() is derived from the
source expression, recent gcc versions will emit a warning, which is
turned into an error by -Werror:

  error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression
    as the source; did you mean to use the size of the destination?
    [-Werror=sizeof-pointer-memaccess]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Gbp-Pq: Topic upstream
Gbp-Pq: Name 0017-harness-Use-destination-strncpy-expression-for-sizeo.patch

harness/cases/19.t
harness/cases/21.t

index 4989510ae14e348b948276e6e4b44e46b91500d2..5c3e0d68b3682e17c1f3436f25c6c71b3a164e38 100644 (file)
@@ -41,7 +41,7 @@ open_temp_file(void)
        int fd;
        char template[sizeof(TEMPLATE)];
 
-       strncpy(template, TEMPLATE, sizeof(TEMPLATE));
+       strncpy(template, TEMPLATE, sizeof(template));
        fd = mkostemp(template, O_DIRECT);
        if (fd < 0) {
                perror("mkstemp");
index 441eaa8db4a993f9e64222ddb57eb6555ad0ee25..fe33a9de66c64738eb49d29286b4d6428b4826f6 100644 (file)
@@ -43,7 +43,7 @@ open_temp_file()
        int fd;
        char temp_file[sizeof(TEMPLATE)];
 
-       strncpy(temp_file, TEMPLATE, sizeof(TEMPLATE));
+       strncpy(temp_file, TEMPLATE, sizeof(temp_file));
        fd = mkstemp(temp_file);
        if (fd < 0) {
                perror("mkstemp");