Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 May 2019 14:43:36 -0600
From:      Alan Somers <asomers@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-projects@freebsd.org
Subject:   Re: svn commit: r348007 - projects/fuse2/lib/libc/gen
Message-ID:  <CAOtMX2i6Z7=QPG3LNBdGLDKE3Gm-JJGQ_jzdAuQPF=JFn9e9yQ@mail.gmail.com>
In-Reply-To: <20190520202210.GT2748@kib.kiev.ua>
References:  <201905201936.x4KJaaIC023310@repo.freebsd.org> <20190520202210.GT2748@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 20, 2019 at 2:22 PM Konstantin Belousov <kostikbel@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 ?
-Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2i6Z7=QPG3LNBdGLDKE3Gm-JJGQ_jzdAuQPF=JFn9e9yQ>