bug-coreutils
[Top][All Lists]
Advanced

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

Re: Incorrect use of USE_XATTR in coreutils-8.4


From: Pádraig Brady
Subject: Re: Incorrect use of USE_XATTR in coreutils-8.4
Date: Fri, 22 Jan 2010 11:57:52 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 18/01/10 10:32, Pádraig Brady wrote:
On 17/01/10 08:03, Jim Meyering wrote:
Thanks!
That would fix it, but please retain the 0/1 semantics, in case
we ever want to use USE_XATTR in a C (as opposed to cpp) expression.

# Map yes,no to 1,0.
AC_DEFINE_UNQUOTED([USE_XATTR],
[`test $use_xattr = yes&& echo 1 || echo 0`],
[Define if you want extended attribute support.])

I know this is not the norm for USE_* variables e.g., in gnulib,
but I have come to appreciate being able to use 0/1 cpp symbols
in C code (albeit not often), for readability.


Also if all variables were defined to something then
we could enable -Wundef which would catch this case:

#define USE_XATTR yes
#if XATTR

Seeing as we're not using -Wundef, I was wondering
whether I could add a syntax-check to catch cases like this.
How about the following? Would it be general enough for
gnulib's maint.mk ?

cheers,
Pádraig.

diff --git a/cfg.mk b/cfg.mk
index b669961..e14155f 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -245,6 +245,14 @@ sc_prohibit_sleep:
        msg='prefer xnanosleep over other sleep interfaces'             \
          $(_prohibit_regexp)

+# "#if HAVE_WHATEVER" will evaluate to false for any non numeric string.
+# That would be flagged by using -Wundef, however gnulib currently
+# tests many undefined macros, and so we can't enable that option.
+# So at least preclude common boolean strings as macro values.
+sc_Wundef_boolean:
+       @grep -Ei '^#define.*(yes|no|true|false)$$' lib/config.h &&     \
+         { echo 'Please use 0 or 1 for macro values' 1>&2; exit 1; }
+
 include $(srcdir)/dist-check.mk

 update-copyright-env = \




reply via email to

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