getvfsbyname: prefer sizeof to strlen even for constants
Clang is smart enough to evaluate strlen() of a constant at compile-time. However, that won't work in the future if we compile libc with -ffreestanding. Reported by: kib Dissenting: ngie, cem Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
d311d6c467
commit
d5fce87d7c
@ -49,10 +49,11 @@ __FBSDID("$FreeBSD$");
|
||||
static bool
|
||||
are_fusefs(const char *fsname, const char *vfc_name)
|
||||
{
|
||||
const char fusefs[] = "fusefs";
|
||||
const char fusefs_dot[] = "fusefs.";
|
||||
const static char fusefs[] = "fusefs";
|
||||
const static char fusefs_dot[] = "fusefs.";
|
||||
|
||||
return (strncmp(fsname, fusefs_dot, strlen(fusefs_dot)) == 0 &&
|
||||
|
||||
return (strncmp(fsname, fusefs_dot, sizeof(fusefs_dot) - 1) == 0 &&
|
||||
strcmp(fusefs, vfc_name) == 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user