]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/futex: getopt() requires int as return value.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 28 May 2025 08:55:19 +0000 (10:55 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 5 Jun 2025 12:37:58 +0000 (14:37 +0200)
Mark reported that futex_priv_hash fails on ARM64.
It turns out that the command line parsing does not terminate properly
and ends in the default case assuming an invalid option was passed.

Use an int as the return type for getopt().

Closes: https://lore.kernel.org/all/31869a69-063f-44a3-a079-ba71b2506cce@sirena.org.uk/
Fixes: 3163369407baf ("selftests/futex: Add futex_numa_mpol")
Fixes: cda95faef7bcf ("selftests/futex: Add futex_priv_hash")
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250528085521.1938355-2-bigeasy@linutronix.de
tools/testing/selftests/futex/functional/futex_numa_mpol.c
tools/testing/selftests/futex/functional/futex_priv_hash.c

index 20a9d3ecf7433cbcf31e583d9e83e666833fb2c3..564dbd02d2f465d1e5b718132eaa4f2f00ae1dfa 100644 (file)
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
        struct futex32_numa *futex_numa;
        int mem_size, i;
        void *futex_ptr;
-       char c;
+       int c;
 
        while ((c = getopt(argc, argv, "chv:")) != -1) {
                switch (c) {
index 2dca18fefedcda9827fbfed36d94f821dbb4d474..24a92dc94eb86cc0e03ded5d6a4a0a96b0dc8a36 100644 (file)
@@ -130,7 +130,7 @@ int main(int argc, char *argv[])
        pthread_mutexattr_t mutex_attr_pi;
        int use_global_hash = 0;
        int ret;
-       char c;
+       int c;
 
        while ((c = getopt(argc, argv, "cghv:")) != -1) {
                switch (c) {