]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
scriptreplay: fix compiler warning
authorKarel Zak <kzak@redhat.com>
Wed, 29 Jan 2025 11:38:46 +0000 (12:38 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 30 Jan 2025 08:39:53 +0000 (09:39 +0100)
compiler warning:
  expected 'struct timeval * restrict' but argument is of type 'const struct timeval *'

On Linux, select() modifies timeout, so the timeout cannot be 'const'.

Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/scriptreplay.c

index 1453d5bbbb718bc3db324129008734ada862c79b..77f0570358a2532d698fc9fa26e4a8bb1afef361 100644 (file)
@@ -107,7 +107,13 @@ delay_for(const struct timeval *delay)
                        break;
        }
 #else
-       select(0, NULL, NULL, NULL, delay);
+       {
+               struct timeval timeout;
+
+               /* On Linux, select() modifies timeout */
+               memcpy(&timeout, delay, sizeof(struct timeval));
+               select(0, NULL, NULL, NULL, &timeout);
+       }
 #endif
 }