From 478dade09a4288f73e963b7f185ef9f73b681b42 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 18 May 2013 17:49:32 -0700 Subject: maint: port --enable-gcc-warnings to clang * configure.ac: If clang, add -Wno-format-extra-args and -Wno-tautological-constant-out-of-range-compare. * gl/lib/rand-isaac.c (ind): * gl/lib/randread.c (readisaac): * src/ls.c (dev_ino_push, dev_ino_pop): * src/sort.c (buffer_linelim): * src/system.h (is_nul): * src/tail.c (tail_forever_inotify): Rewrite to avoid casts that clang dislikes. It's good to avoid casts anyway. * src/expr.c (integer_overflow): Declare only if it exists. (die): Remove; unused. * src/ls.c (dev_ino_push): New function, replacing ... (DEV_INO_PUSH): ... this removed macro. All uses changed. (decode_switches): Rewrite "str"+i to &str[i]. --- src/system.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/system.h') diff --git a/src/system.h b/src/system.h index 94c968fbd..db8931635 100644 --- a/src/system.h +++ b/src/system.h @@ -496,21 +496,24 @@ ptr_align (void const *ptr, size_t alignment) Note the word after the buffer must be non NUL. */ static inline bool _GL_ATTRIBUTE_PURE -is_nul (const char *buf, size_t bufsize) +is_nul (void const *buf, size_t bufsize) { typedef uintptr_t word; + void const *vp; + char const *cbuf = buf; + word const *wp = buf; /* Find first nonzero *word*, or the word with the sentinel. */ - word *wp = (word *) buf; while (*wp++ == 0) continue; /* Find the first nonzero *byte*, or the sentinel. */ - char *cp = (char *) (wp - 1); + vp = wp - 1; + char const *cp = vp; while (*cp++ == 0) continue; - return cp > buf + bufsize; + return cbuf + bufsize < cp; } /* If 10*Accum + Digit_val is larger than the maximum value for Type, -- cgit v1.2.3-54-g00ecf