summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c14
-rw-r--r--src/ls.c38
-rw-r--r--src/sort.c3
-rw-r--r--src/system.h11
-rw-r--r--src/tail.c4
5 files changed, 38 insertions, 32 deletions
diff --git a/src/expr.c b/src/expr.c
index b4fa808a0..9d21ca87f 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -44,8 +44,6 @@
int, the widest unsigned type that GMP supports. */
verify (SIZE_MAX <= ULONG_MAX);
-static void integer_overflow (char) ATTRIBUTE_NORETURN;
-
#ifndef HAVE_GMP
# define HAVE_GMP 0
#endif
@@ -53,6 +51,7 @@ static void integer_overflow (char) ATTRIBUTE_NORETURN;
#if HAVE_GMP
# include <gmp.h>
#else
+static void integer_overflow (char) ATTRIBUTE_NORETURN;
/* Approximate gmp.h well enough for expr.c's purposes. */
typedef intmax_t mpz_t[1];
static void mpz_clear (mpz_t z) { (void) z; }
@@ -278,6 +277,7 @@ syntax_error (void)
error (EXPR_INVALID, 0, _("syntax error"));
}
+#if ! HAVE_GMP
/* Report an integer overflow for operation OP and exit. */
static void
integer_overflow (char op)
@@ -285,15 +285,7 @@ integer_overflow (char op)
error (EXPR_FAILURE, ERANGE, "%c", op);
abort (); /* notreached */
}
-
-static void die (int errno_val, char const *msg)
- ATTRIBUTE_NORETURN;
-static void
-die (int errno_val, char const *msg)
-{
- error (EXPR_FAILURE, errno_val, "%s", msg);
- abort (); /* notreached */
-}
+#endif
int
main (int argc, char **argv)
diff --git a/src/ls.c b/src/ls.c
index d9876f842..72aee994f 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -962,25 +962,33 @@ static struct obstack subdired_obstack;
static struct obstack dev_ino_obstack;
/* Push a pair onto the device/inode stack. */
-#define DEV_INO_PUSH(Dev, Ino) \
- do \
- { \
- struct dev_ino *di; \
- obstack_blank (&dev_ino_obstack, sizeof (struct dev_ino)); \
- di = -1 + (struct dev_ino *) obstack_next_free (&dev_ino_obstack); \
- di->st_dev = (Dev); \
- di->st_ino = (Ino); \
- } \
- while (0)
+static void
+dev_ino_push (dev_t dev, ino_t ino)
+{
+ void *vdi;
+ struct dev_ino *di;
+ int dev_ino_size = sizeof *di;
+ obstack_blank (&dev_ino_obstack, dev_ino_size);
+ vdi = obstack_next_free (&dev_ino_obstack);
+ di = vdi;
+ di--;
+ di->st_dev = dev;
+ di->st_ino = ino;
+}
/* Pop a dev/ino struct off the global dev_ino_obstack
and return that struct. */
static struct dev_ino
dev_ino_pop (void)
{
- assert (sizeof (struct dev_ino) <= obstack_object_size (&dev_ino_obstack));
- obstack_blank (&dev_ino_obstack, -(int) (sizeof (struct dev_ino)));
- return *(struct dev_ino *) obstack_next_free (&dev_ino_obstack);
+ void *vdi;
+ struct dev_ino *di;
+ int dev_ino_size = sizeof *di;
+ assert (dev_ino_size <= obstack_object_size (&dev_ino_obstack));
+ obstack_blank (&dev_ino_obstack, -dev_ino_size);
+ vdi = obstack_next_free (&dev_ino_obstack);
+ di = vdi;
+ return *di;
}
/* Note the use commented out below:
@@ -1978,7 +1986,7 @@ decode_switches (int argc, char **argv)
if (file_type <= indicator_style)
{
char const *p;
- for (p = "*=>@|" + indicator_style - file_type; *p; p++)
+ for (p = &"*=>@|"[indicator_style - file_type]; *p; p++)
set_char_quoting (filename_quoting_options, *p, 1);
}
@@ -2542,7 +2550,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
return;
}
- DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
+ dev_ino_push (dir_stat.st_dev, dir_stat.st_ino);
}
if (recursive || print_dir_name)
diff --git a/src/sort.c b/src/sort.c
index 7410abca6..062b5f946 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1557,7 +1557,8 @@ initbuf (struct buffer *buf, size_t line_bytes, size_t alloc)
static inline struct line *
buffer_linelim (struct buffer const *buf)
{
- return (struct line *) (buf->buf + buf->alloc);
+ void *linelim = buf->buf + buf->alloc;
+ return linelim;
}
/* Return a pointer to the first character of the field specified
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,
diff --git a/src/tail.c b/src/tail.c
index 6bbc7251f..0f1a37c07 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1446,6 +1446,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
{
struct File_spec *fspec;
struct inotify_event *ev;
+ void *void_ev;
/* When following by name without --retry, and the last file has
been unlinked or renamed-away, diagnose it and return. */
@@ -1507,7 +1508,8 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
error (EXIT_FAILURE, errno, _("error reading inotify event"));
}
- ev = (struct inotify_event *) (evbuf + evbuf_off);
+ void_ev = evbuf + evbuf_off;
+ ev = void_ev;
evbuf_off += sizeof (*ev) + ev->len;
if (ev->len) /* event on ev->name in watched directory */