Fix the following warning by ensuring strrchr() return type is set to
'const char *' if its input is declared as such.
src/tools.c: In function ‘str2net’:
src/tools.c:1618:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1618 | if ((c = strrchr(str, '/')) != NULL) {
| ^
This build warning was introduced by the following patch.
9bc6c4d18c2ea9836c171977c1c7c2979ecbb132
OPTIM: tools/str2net: only duplicate the string when a slash is present
This change is required since C23, as strrchr(), along other functions
which accept a const-qualified pointer without returning a const type
are now declared as macro with generics to preserve the const qualifier.
See https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3020.pdf for
details.
No need to backport, unless the above patch is.
{
__label__ out_free, out_err;
char *s = NULL;
- char *c;
+ const char *c;
int ret_val;
memset(mask, 0, sizeof(*mask));
int str62net(const char *str, struct in6_addr *addr, unsigned char *mask)
{
char *s = NULL;
- char *c;
+ const char *c;
int ret_val = 0;
char *err;
unsigned long len = 128;