mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 17:50:16 +01:00
all: don't accept %NULL as delimiters for nm_utils_strsplit_set()
The caller should make a conscious decision which delimiters to use. Unfortunately, there is a variety of different demiters in use. This should be unitfied and the callers should use one of a few specific set of delimiters. This could be unified by (re)using a define as delimiters, like strv = nm_utils_strsplit_set_full (value, MULTILIST_WITH_ESCAPE_CHARS, NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); where MULTILIST_WITH_ESCAPE_CHARS has a particular meaning that should be reused for similar uses. However, leaving the delimiter at NULL is not good because it's unclear who wants that default behavior (and what the default should be). Don't allow that. There are almost no callers that relied on this default anyway.
This commit is contained in:
parent
84f2037648
commit
ce456f5b77
2 changed files with 5 additions and 4 deletions
|
|
@ -974,8 +974,7 @@ _char_lookup_table_init (guint8 lookup[static 256],
|
|||
/**
|
||||
* nm_utils_strsplit_set_full:
|
||||
* @str: the string to split.
|
||||
* @delimiters: the set of delimiters. If %NULL, defaults to " \t\n",
|
||||
* like bash's $IFS.
|
||||
* @delimiters: the set of delimiters.
|
||||
* @flags: additional flags for controlling the operation.
|
||||
*
|
||||
* This is a replacement for g_strsplit_set() which avoids copying
|
||||
|
|
@ -1017,8 +1016,10 @@ nm_utils_strsplit_set_full (const char *str,
|
|||
return NULL;
|
||||
|
||||
/* initialize lookup table for delimiter */
|
||||
if (!delimiters)
|
||||
if (!delimiters) {
|
||||
nm_assert_not_reached ();
|
||||
delimiters = " \t\n";
|
||||
}
|
||||
|
||||
_char_lookup_table_init (delimiters_table, delimiters);
|
||||
|
||||
|
|
|
|||
|
|
@ -4147,7 +4147,7 @@ parse_ethtool_option (const char *value,
|
|||
gs_free const char **words = NULL;
|
||||
guint i;
|
||||
|
||||
words = nm_utils_strsplit_set (value, NULL);
|
||||
words = nm_utils_strsplit_set (value, " \t\n");
|
||||
if (!words)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue