mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2026-03-04 19:48:11 +01:00
client: Fix issue with const return value from strrchr
When compiling iwd with recent gcc and glibc-2.43 the --Wdiscarded-qualifiers
warning occurs because with ISO C23, the function strrrchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type.
client/known-networks.c: In function 'known_network_proxy_find_by_name':
client/known-networks.c:296:29: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
296 | char *dot = strrchr(name, '.');
| ^~~~~~~
The warning hints to real bug since *dot should not be modified since
*name is actually const to begin with. Change the code to utilize a copy
of the name value if needed.
Reported-by: Rudi Heitbaum <rudi@heitbaum.com>
This commit is contained in:
parent
d5818134bd
commit
a0751085a8
@ -279,35 +279,35 @@ static const struct proxy_interface *known_network_proxy_find_by_name(
|
||||
struct network_args network_args;
|
||||
struct l_queue *match;
|
||||
const struct proxy_interface *proxy;
|
||||
size_t name_len;
|
||||
char *args_name;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
if (l_str_has_suffix(name, ".psk"))
|
||||
name_len = strlen(name);
|
||||
|
||||
if (l_str_has_suffix(name, ".psk")) {
|
||||
network_args.type = "psk";
|
||||
else if (l_str_has_suffix(name, ".8021x"))
|
||||
name_len -= 4;
|
||||
} else if (l_str_has_suffix(name, ".8021x")) {
|
||||
network_args.type = "8021x";
|
||||
else if (l_str_has_suffix(name, ".open"))
|
||||
name_len -= 6;
|
||||
} else if (l_str_has_suffix(name, ".open")) {
|
||||
network_args.type = "open";
|
||||
else
|
||||
name_len -= 5;
|
||||
} else
|
||||
network_args.type = NULL;
|
||||
|
||||
if (network_args.type) {
|
||||
char *dot = strrchr(name, '.');
|
||||
|
||||
if (!dot)
|
||||
/* This shouldn't ever be the case */
|
||||
return NULL;
|
||||
|
||||
*dot = '\0';
|
||||
}
|
||||
|
||||
network_args.name = name;
|
||||
args_name = l_strndup(name, name_len);
|
||||
network_args.name = args_name;
|
||||
|
||||
match = proxy_interface_find_all(known_network_interface_type.interface,
|
||||
known_network_match,
|
||||
&network_args);
|
||||
|
||||
l_free(args_name);
|
||||
|
||||
if (!match) {
|
||||
display("No network with specified parameters was found\n");
|
||||
return NULL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user