Re: [PATCH] internal: Use g_strcmp0 in STR(N)EQ_NULLABLE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 24, 2019 at 03:29:27PM +0100, Daniel P. Berrangé wrote:
> On Thu, Oct 24, 2019 at 04:22:09PM +0200, Pavel Hrdina wrote:
> > On Thu, Oct 24, 2019 at 04:12:00PM +0200, Peter Krempa wrote:
> > > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> > > ---
> > >  src/internal.h | 6 ++----
> > >  1 file changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/src/internal.h b/src/internal.h
> > > index 5b0a2335f5..0ff9f496ac 100644
> > > --- a/src/internal.h
> > > +++ b/src/internal.h
> > > @@ -86,10 +86,8 @@
> > >  #define STRCASEPREFIX(a, b) (c_strncasecmp(a, b, strlen(b)) == 0)
> > >  #define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL)
> > > 
> > > -#define STREQ_NULLABLE(a, b) \
> > > -    ((a) ? (b) && STREQ((a), (b)) : !(b))
> > > -#define STRNEQ_NULLABLE(a, b) \
> > > -    ((a) ? !(b) || STRNEQ((a), (b)) : !!(b))
> > > +#define STREQ_NULLABLE(a, b) (g_strcmp0(a, b) == 0)
> > > +#define STRNEQ_NULLABLE(a, b) (g_strcmp0(a, b) != 0)
> > 
> > Why not use g_strcmp0 directly?
> 
> The same reason we never used  strcmp() in the first place - it is
> easier to read STREQ vs  strcmp == 0 / strcmp != 0.

Right, I was looking at g_str_equal() which returns gboolean and for
some reason didn't realized that g_strcmp0 returns int.  Only if there
would be g_str_equal0().

Pavel

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux