Skip to content

warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-quaLifiers] #116

Description

@heitbaum

When building latest busybox with gcc-15/16 and glibc-2.43 the following warnings occur.

archival/libarchive/unsafe_prefix.c: In function 'strip_unsafe_prefix':
archival/libarchive/unsafe_prefix.c:21:21: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qua
lifiers]
   21 |                 cp2 = strstr(cp, "/../");
      |                     ^
coreutils/od_bloaty.c: In function 'parse_old_offset':
coreutils/od_bloaty.c:1175:11: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1175 |         p = strchr(s, '.');
      |           ^
coreutils/od_bloaty.c: In function 'od_main':
coreutils/od_bloaty.c:1239:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1239 |                 p = strchr(doxn, str_A[0]);
      |                   ^
coreutils/printf.c: In function 'print_formatted':
coreutils/printf.c:357:43: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  357 |                                 char *p = strchr(format_chars, *f);
      |                                           ^~~~~~
editors/awk.c: In function 'exec_builtin':
editors/awk.c:2850:43: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2850 |                                 char *s = strstr(as[0], as[1]);
      |                                           ^~~~~~
libbb/get_last_path_component.c: In function 'bb_get_last_path_component_nostrip':
libbb/get_last_path_component.c:27:23: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qua
lifiers]
   27 |         char *slash = strrchr(path, '/');
      |                       ^~~~~~~
libbb/replace.c: In function 'xmalloc_substitute_string':
libbb/replace.c:39:21: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   39 |         while ((end = strstr(src, sub)) != NULL) {
      |                     ^
libbb/strrstr.c: In function 'strrstr':
libbb/strrstr.c:22:27: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   22 |                 char *p = strstr(haystack, needle);
      |                           ^~~~~~
libbb/xfuncs_printf.c: In function 'bb_unsetenv':
libbb/xfuncs_printf.c:366:12: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  366 |         tp = strchr(var, '=');
      |            ^
libpwdgrp/uidgid_get.c: In function 'get_uidgid':
libpwdgrp/uidgid_get.c:39:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   39 |         group = strchr(ug, ':');
      |               ^
networking/ifconfig.c: In function 'ifconfig_main':
networking/ifconfig.c:438:64: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  438 |                                                         prefix = strchr(host, '/');
      |                                                                ^
networking/nbd-client.c: In function 'nbdclient_main':
networking/nbd-client.c:263:35: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers
]
  263 |                         char *s = strrchr(device, '/');
      |                                   ^~~~~~~
networking/route.c: In function 'INET_setroute':
networking/route.c:186:24: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  186 |                 prefix = strchr(target, '/');
      |                        ^
networking/route.c: In function 'INET6_setroute':
networking/route.c:364:28: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  364 |                         cp = strchr(target, '/'); /* Yes... const to non is ok. */
      |                            ^
shell/ash.c: In function 'find_builtin':
shell/ash.c:10291:12: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
10291 |         bp = bsearch(
      |            ^
shell/ash.c: In function 'decode_dollar_squote':
shell/ash.c:12421:11: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
12421 |         p = strchr(C_escapes, c);
      |           ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions