summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-05-18 17:49:32 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-05-18 17:55:07 -0700
commit478dade09a4288f73e963b7f185ef9f73b681b42 (patch)
treedf50bffa4c4d045b20ead3e3d945e39108088acc /gl
parente605e40acf859eea2a1221d867ab3c086a1a1c15 (diff)
downloadcoreutils-478dade09a4288f73e963b7f185ef9f73b681b42.tar.xz
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].
Diffstat (limited to 'gl')
-rw-r--r--gl/lib/rand-isaac.c24
-rw-r--r--gl/lib/randread.c10
2 files changed, 23 insertions, 11 deletions
diff --git a/gl/lib/rand-isaac.c b/gl/lib/rand-isaac.c
index defd21778..04af2e782 100644
--- a/gl/lib/rand-isaac.c
+++ b/gl/lib/rand-isaac.c
@@ -58,16 +58,26 @@ just (isaac_word a)
return a & desired_bits;
}
-/* The index operation. On typical machines whose words are exactly
- the right size, this is optimized to a mask, an addition, and an
- indirect load. Atypical machines need more work. */
+/* The index operation. */
static inline isaac_word
ind (isaac_word const *m, isaac_word x)
{
- return (sizeof *m * CHAR_BIT == ISAAC_BITS
- ? (* (isaac_word *) ((char *) m
- + (x & ((ISAAC_WORDS - 1) * sizeof *m))))
- : m[(x / (ISAAC_BITS / CHAR_BIT)) & (ISAAC_WORDS - 1)]);
+ if (sizeof *m * CHAR_BIT == ISAAC_BITS)
+ {
+ /* The typical case, where words are exactly the right size.
+ Optimize this to a mask, an addition, and an indirect
+ load. */
+ void const *void_m = m;
+ char const *base_p = void_m;
+ void const *word_p = base_p + (x & ((ISAAC_WORDS - 1) * sizeof *m));
+ isaac_word const *p = word_p;
+ return *p;
+ }
+ else
+ {
+ /* Atypical machines need more work. */
+ return m[(x / (ISAAC_BITS / CHAR_BIT)) & (ISAAC_WORDS - 1)];
+ }
}
/* Use and update *S to generate random data to fill RESULT. */
diff --git a/gl/lib/randread.c b/gl/lib/randread.c
index dfba61182..8ee384751 100644
--- a/gl/lib/randread.c
+++ b/gl/lib/randread.c
@@ -275,12 +275,14 @@ readsource (struct randread_source *s, unsigned char *p, size_t size)
the buffered ISAAC generator in ISAAC. */
static void
-readisaac (struct isaac *isaac, unsigned char *p, size_t size)
+readisaac (struct isaac *isaac, void *p, size_t size)
{
size_t inbytes = isaac->buffered;
while (true)
{
+ char *char_p = p;
+
if (size <= inbytes)
{
memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, size);
@@ -289,14 +291,14 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size)
}
memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, inbytes);
- p += inbytes;
+ p = char_p + inbytes;
size -= inbytes;
/* If P is aligned, write to *P directly to avoid the overhead
of copying from the buffer. */
if (ALIGNED_POINTER (p, isaac_word))
{
- isaac_word *wp = (isaac_word *) p;
+ isaac_word *wp = p;
while (ISAAC_BYTES <= size)
{
isaac_refill (&isaac->state, wp);
@@ -308,7 +310,7 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size)
return;
}
}
- p = (unsigned char *) wp;
+ p = wp;
}
isaac_refill (&isaac->state, isaac->data.w);