]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg: Fix compiler warning
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 18 Feb 2026 17:26:52 +0000 (18:26 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 18 Feb 2026 17:26:52 +0000 (18:26 +0100)
Seen compiler warning with GCC 15.2.1 and glibc 2.43:
```
text-utils/pg.c: In function ‘prompt’:
text-utils/pg.c:621:24: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  621 |                 if ((p = strstr(pstring, "%d")) == NULL) {
      |                        ^
```

This happens if strstr is actually a preprocessor definition with a
__glibc_const_generic. For this, __GLIBC_USE (ISOC23) must be true.

Setting the pointer to const does not hurt and clarifies that the
content is not modfied.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
text-utils/pg.c

index d27f52ac60213e6bb48695c6ed60ec9686abb4f7..81eba938ccd69fc3fd0d4b899d21907db4fb3cde 100644 (file)
@@ -615,7 +615,8 @@ static void prompt(long long pageno)
        char key;
        int state = COUNT;
        int escape = 0;
-       char b[LINE_MAX], *p;
+       char b[LINE_MAX];
+       const char *p;
 
        if (pageno != -1) {
                if ((p = strstr(pstring, "%d")) == NULL) {