string-util: add strstrafter()
strstrafter() is like strstr() but returns a pointer to the first character *after* the found substring, not on the substring itself. Quite often this is what we actually want. Inspired by #27267 I think it makes sense to add a helper for this, to avoid the potentially fragile manual pointer increment afterwards.
This commit is contained in:
@@ -559,12 +559,12 @@ int dev_is_devtmpfs(void) {
|
||||
if (mid != mount_id)
|
||||
continue;
|
||||
|
||||
e = strstr(line, " - ");
|
||||
e = strstrafter(line, " - ");
|
||||
if (!e)
|
||||
continue;
|
||||
|
||||
/* accept any name that starts with the currently expected type */
|
||||
if (startswith(e + 3, "devtmpfs"))
|
||||
if (startswith(e, "devtmpfs"))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user