bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] A new module called streq_macros that provides STREQ and STR


From: Eric Blake
Subject: Re: [PATCH] A new module called streq_macros that provides STREQ and STRNEQ
Date: Wed, 21 May 2014 13:49:09 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 05/21/2014 01:15 PM, Kieran Colford wrote:
> ---
>  modules/streq_macros |   24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 modules/streq_macros
> 
> diff --git a/modules/streq_macros b/modules/streq_macros
> new file mode 100644
> index 0000000..8a02ee9
> --- /dev/null
> +++ b/modules/streq_macros
> @@ -0,0 +1,24 @@
> +Description:
> +Add the macros STREQ and STRNEQ to config.h.  This adds the
> +functionality that is looked for by sc_prohibit_strcmp from the
> +maintainer-makefile.
> +
> +Files:
> +
> +Depends-on:
> +
> +configure.ac:
> +AC_DEFINE([STREQ(X, Y)], [((X) != NULL && (Y) != NULL && strcmp (X, Y) == 
> 0)],
> +       [test if X and Y are not NULL and are equal])

This definition does not match the one used elsewhere in gnulib:

#define STREQ(a, b) (strcmp (a, b) == 0)

It evaluates its arguments more than once (which some projects may not
be expecting).  At least libvirt has a macro named STREQ_NULLABLE() for
the purpose of comparing two pointers for string equality which allows
NULL, while reserving STREQ() for guaranteed non-null pointer
comparisons.  Even if we want to allow for NULL, then I'd highly
recommend that two null pointers should compare equal (in your
implementation, STREQ(NULL, NULL) returns false).


> +License:
> +LGPL

Any problem with making it LGPLv2+?  Plain LGPL is equivalent to the
current LGPL (LGPLv3+ at the moment), and locks out use from projects
that are still stuck on LGPLv2.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]