svn commit: r348007 - projects/fuse2/lib/libc/gen
Konstantin Belousov
kostikbel at gmail.com
Mon May 20 20:51:05 UTC 2019
On Mon, May 20, 2019 at 02:43:36PM -0600, Alan Somers wrote:
> On Mon, May 20, 2019 at 2:22 PM Konstantin Belousov <kostikbel at gmail.com> wrote:
> >
> > On Mon, May 20, 2019 at 07:36:36PM +0000, Alan Somers wrote:
> > > +static bool
> > > +are_fusefs(const char *fsname, const char *vfc_name)
> > > +{
> > > + const char fusefs[] = "fusefs";
> > > + const char fusefs_dot[] = "fusefs.";
> > Both arrays should be static.
>
> Ok.
>
> >
> > > +
> > > + return (strncmp(fsname, fusefs_dot, strlen(fusefs_dot)) == 0 &&
> > strlen() is not needed, you can use sizeof() - 1.
> >
> > > + strcmp(fusefs, vfc_name) == 0);
> > > +}
>
> True, but I though that strlen would be more readable. Clang is smart
> enough to realize that strlen's argument is a constant and omit the
> call to strlen, so that's what I went with. Is there any other reason
> to prefer sizeof() - 1 ?
The reason is that it would also work for not so smart compiler, or with
a smart compiler after we finally turn on -ffreestanding for libc, as it
ought to be.
More information about the svn-src-projects
mailing list