svn commit: r348054 - projects/fuse2/lib/libc/gen

Alan Somers asomers at FreeBSD.org
Tue May 21 15:59:19 UTC 2019


Author: asomers
Date: Tue May 21 15:59:17 2019
New Revision: 348054
URL: https://svnweb.freebsd.org/changeset/base/348054

Log:
  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

Modified:
  projects/fuse2/lib/libc/gen/getvfsbyname.c

Modified: projects/fuse2/lib/libc/gen/getvfsbyname.c
==============================================================================
--- projects/fuse2/lib/libc/gen/getvfsbyname.c	Tue May 21 15:19:49 2019	(r348053)
+++ projects/fuse2/lib/libc/gen/getvfsbyname.c	Tue May 21 15:59:17 2019	(r348054)
@@ -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);
 }
 


More information about the svn-src-projects mailing list