mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-20 03:30:09 +01:00
nm-udev-utils: constify strstr-output variable
`subsystem_full` is const, so `s` needs to be const too. Reorder the NULL-byte write so that we are not writing into a const char* (the underlying memory is the same).
This commit is contained in:
parent
487ca30256
commit
5f6beb0e57
1 changed files with 8 additions and 7 deletions
|
|
@ -92,7 +92,8 @@ _subsystem_split(const char *subsystem_full,
|
|||
const char **out_devtype,
|
||||
char **to_free)
|
||||
{
|
||||
char *tmp, *s;
|
||||
char *tmp;
|
||||
const char *s;
|
||||
|
||||
nm_assert(subsystem_full);
|
||||
nm_assert(out_subsystem);
|
||||
|
|
@ -101,12 +102,12 @@ _subsystem_split(const char *subsystem_full,
|
|||
|
||||
s = strstr(subsystem_full, "/");
|
||||
if (s) {
|
||||
tmp = g_strdup(subsystem_full);
|
||||
s = &tmp[s - subsystem_full];
|
||||
*s = '\0';
|
||||
*out_subsystem = tmp;
|
||||
*out_devtype = &s[1];
|
||||
*to_free = tmp;
|
||||
tmp = g_strdup(subsystem_full);
|
||||
tmp[s - subsystem_full] = '\0';
|
||||
s = &tmp[s - subsystem_full];
|
||||
*out_subsystem = tmp;
|
||||
*out_devtype = &s[1];
|
||||
*to_free = tmp;
|
||||
} else {
|
||||
*out_subsystem = subsystem_full;
|
||||
*out_devtype = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue