]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
manual: Allow getsubopt example to compile with GCC 15.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 28 Sep 2025 22:10:52 +0000 (15:10 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Tue, 30 Sep 2025 00:01:54 +0000 (17:01 -0700)
GCC 15 turned -Wincompatible-pointer-types into a compiler error instead
of a warning by default. This patch prevents the following error:

    $ gcc manual/examples/subopt.c
    manual/examples/subopt.c: In function ‘main’:
    manual/examples/subopt.c:64:40: error: passing argument 2 of ‘getsubopt’ from incompatible pointer type [-Wincompatible-pointer-types]
       64 |           switch (getsubopt (&subopts, mount_opts, &value))
          |                                        ^~~~~~~~~~
          |                                        |
          |                                        const char **
    In file included from manual/examples/subopt.c:19:
    /usr/include/stdlib.h:1100:47: note: expected ‘char * const* restrict’ but argument is of type ‘const char **’
     1100 |                       char *const *__restrict __tokens,
          |                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
manual/examples/subopt.c

index e7a073099adccee41e6f2e5637c2c84c94934b65..63b5271483ab3575dd09bbc6642c67920ce6cc56 100644 (file)
@@ -61,7 +61,7 @@ main (int argc, char **argv)
       case 'o':
         subopts = optarg;
         while (*subopts != '\0')
-          switch (getsubopt (&subopts, mount_opts, &value))
+          switch (getsubopt (&subopts, (char * const *) mount_opts, &value))
             {
             case RO_OPTION:
               read_only = 1;