diff options
author | Jim Meyering <meyering@redhat.com> | 2008-08-08 10:06:54 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-08-09 16:56:01 +0200 |
commit | c339cff4a6af0c83de0e32e6766258d35f0b9cb6 (patch) | |
tree | 0c3e568662d86ae50eb22ad39061bff7ecdfe50c | |
parent | ae5ae5e117baa30d9ab33dafd51eb3900c28cea6 (diff) | |
download | coreutils-c339cff4a6af0c83de0e32e6766258d35f0b9cb6.tar.xz |
expr: avoid compiler warnings
* src/expr.c (die): New "noreturn" function to wrap one-arg use of
error
(string_too_long): Use die rather than error.
(toint): Remove definition of now-unused function.
(eval6): Remove a little duplication.
Use die rather than error.
(dodivide): Remove declaration of now-unused variable.
-rw-r--r-- | src/expr.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/src/expr.c b/src/expr.c index bf55a4029..524ec9301 100644 --- a/src/expr.c +++ b/src/expr.c @@ -225,10 +225,20 @@ integer_overflow (char op) "but arbitrary-precision arithmetic is not available"), op); } +static void die (int exit_status, int errno_val, char const *msg) + ATTRIBUTE_NORETURN; +static void +die (int exit_status, int errno_val, char const *msg) +{ + assert (exit_status != 0); + error (exit_status, errno_val, "%s", msg); + abort (); /* notreached */ +} + static void string_too_long (void) { - error (EXPR_FAILURE, ERANGE, _("string too long")); + die (EXPR_FAILURE, ERANGE, _("string too long")); } enum @@ -543,33 +553,6 @@ toarith (VALUE *v) } } -/* Convert V into an integer (that is, a non-arbitrary-precision value) - Return true on success, false on failure. */ -static bool -toint (VALUE *v) -{ - if (!toarith (v)) - return false; -#if HAVE_GMP - if (v->type == mp_integer) - { - if (mpz_fits_slong_p (v->u.z)) - { - long value = mpz_get_si (v->u.z); - mpz_clear (v->u.z); - v->u.i = value; - v->type = integer; - } - else - return false; /* value was too big. */ - } -#else - if (v->type == mp_integer) - abort (); /* should not happen. */ -#endif - return true; -} - /* Extract a size_t value from a positive arithmetic value, V. The extracted value is stored in *VAL. */ static bool @@ -829,10 +812,10 @@ eval6 (bool evaluate) v->type = mp_integer; } else - string_too_long (); -#else - string_too_long (); #endif + { + string_too_long (); + } } } freev (l); @@ -865,14 +848,12 @@ eval6 (bool evaluate) if (negative) v = str_value (""); else - error (EXPR_FAILURE, ERANGE, - _("string offset is too large")); + die (EXPR_FAILURE, ERANGE, _("string offset is too large")); else if (negative) v = str_value (""); else - error (EXPR_FAILURE, ERANGE, - _("substring length too large")); + die (EXPR_FAILURE, ERANGE, _("substring length too large")); } freev (l); freev (i1); @@ -1025,7 +1006,6 @@ dodivide (VALUE *l, VALUE *r, bool want_modulus) and R is not 0. */ #if HAVE_GMP { - bool round_up = false; /* do we round up? */ int sign_l, sign_r; promote (l); promote (r); |