core, impl: drop const qualifier from split outputs

We write into the buffer returned by nm_strsplit_set_full(), even
though it is returned as `const char**`. The function description
claims this is fine:

> *   It is however safe and allowed to modify the individual strings in-place,
> *   like "g_strstrip((char *) iter[0])".

Remove the const qualifier via cast so that it does not raise errors.
This commit is contained in:
Jan Vaclav 2025-12-02 14:59:19 +01:00
parent 754b87e1c4
commit ac427b25fb
2 changed files with 11 additions and 11 deletions

View file

@ -32,11 +32,11 @@ ip4_process_dhcpcd_rfc3442_routes(const char *iface,
in_addr_t address,
guint32 *out_gwaddr)
{
gs_free const char **routes = NULL;
const char **r;
gboolean have_routes = FALSE;
gs_free char **routes = NULL;
char **r;
gboolean have_routes = FALSE;
routes = nm_strsplit_set(str, " ");
routes = (char **) nm_strsplit_set(str, " ");
if (!routes)
return FALSE;

View file

@ -472,17 +472,17 @@ nm_bridge_vlan_to_str(const NMBridgeVlan *vlan, GError **error)
NMBridgeVlan *
nm_bridge_vlan_from_str(const char *str, GError **error)
{
NMBridgeVlan *vlan = NULL;
gs_free const char **tokens = NULL;
guint i, vid_start, vid_end = 0;
gboolean pvid = FALSE;
gboolean untagged = FALSE;
char *c;
NMBridgeVlan *vlan = NULL;
gs_free char **tokens = NULL;
guint i, vid_start, vid_end = 0;
gboolean pvid = FALSE;
gboolean untagged = FALSE;
char *c;
g_return_val_if_fail(str, NULL);
g_return_val_if_fail(!error || !*error, NULL);
tokens = nm_utils_escaped_tokens_split(str, NM_ASCII_SPACES);
tokens = (char **) nm_utils_escaped_tokens_split(str, NM_ASCII_SPACES);
if (!tokens || !tokens[0]) {
g_set_error_literal(error,
NM_CONNECTION_ERROR,