On Sat, Oct 15, 2016 at 3:57 PM, Pádraig Brady <[email protected]> wrote: > On 15/10/16 18:11, Pádraig Brady wrote: >> I'll do the follow up patch to use [die] in more places. > > A boring copy/replace patch: > 84 files changed, 875 insertions(+), 800 deletions(-) > (extra insertions are the inclusion of die.h) > > One interesting bit is a new syntax check: > > # Usage of error() with an constant to exit() with, should instead use die(), > # as that avoids warnings and may generate better code, due to being apparent > # to the compiler that it doesn't return. > sc_die_EXIT_FAILURE: > @cd $(srcdir)/src && GIT_PAGER= git grep -E \ > 'error \(.*_(FAILURE|INVALID)' \ > && { echo '$(ME): '"Use die() instead of error" 1>&2; \ > exit 1; } \ > || : > > will push later...
Thanks. Here's one more change I'll push today. It removes a few now-useless calls to "abort" after die, and by a similar token, removes some "break;" statements after abort:
From f8b8bbc1b97c9cb7a56aae79451bf87ab7307cd2 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 16 Oct 2016 11:28:39 -0700 Subject: [PATCH] maint: we use die; remove now-unnecessary uses of abort * src/expr.c (integer_overflow): Remove an abort-after-die. * src/paste.c (write_error): Likewise. * src/sort.c (badfieldspec): Likewise. * src/tr.c (string2_extend): Likewise. Also remove a few break statements, each after an abort. --- src/expr.c | 1 - src/paste.c | 1 - src/sort.c | 2 -- src/tr.c | 7 ------- 4 files changed, 11 deletions(-) diff --git a/src/expr.c b/src/expr.c index d7106ec..50e2283 100644 --- a/src/expr.c +++ b/src/expr.c @@ -283,7 +283,6 @@ static void integer_overflow (char op) { die (EXPR_FAILURE, ERANGE, "%c", op); - abort (); /* notreached */ } #endif diff --git a/src/paste.c b/src/paste.c index d6e4b75..0cf5d2f 100644 --- a/src/paste.c +++ b/src/paste.c @@ -161,7 +161,6 @@ static void write_error (void) { die (EXIT_FAILURE, errno, _("write error")); - abort (); } /* Output a single byte, reporting any write errors. */ diff --git a/src/sort.c b/src/sort.c index 5f62d28..6d2eec5 100644 --- a/src/sort.c +++ b/src/sort.c @@ -4036,7 +4036,6 @@ badfieldspec (char const *spec, char const *msgid) { die (SORT_FAILURE, 0, _("%s: invalid field specification %s"), _(msgid), quote (spec)); - abort (); } /* Report incompatible options. */ @@ -4046,7 +4045,6 @@ static void incompatible_options (char const *opts) { die (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts)); - abort (); } /* Check compatibility of ordering options. */ diff --git a/src/tr.c b/src/tr.c index cdf4ccd..62048aa 100644 --- a/src/tr.c +++ b/src/tr.c @@ -408,7 +408,6 @@ is_char_class_member (enum Char_class char_class, unsigned char c) break; default: abort (); - break; } return !! result; @@ -1128,7 +1127,6 @@ get_next (struct Spec_list *s, enum Upper_Lower_class *class) default: abort (); - break; } return return_val; @@ -1301,7 +1299,6 @@ get_spec_stats (struct Spec_list *s) default: abort (); - break; } /* Check for arithmetic overflow in computing length. Also, reject @@ -1396,8 +1393,6 @@ string2_extend (const struct Spec_list *s1, struct Spec_list *s2) die (EXIT_FAILURE, 0, _("when translating with string1 longer than string2,\nthe\ latter string must not end with a character class")); - abort (); /* inform gcc that the above use of error never returns. */ - break; case RE_REPEATED_CHAR: char_to_repeat = p->u.repeated_char.the_repeated_char; @@ -1407,11 +1402,9 @@ string2_extend (const struct Spec_list *s1, struct Spec_list *s2) /* This shouldn't happen, because validate exits with an error if it finds an equiv class in string2 when translating. */ abort (); - break; default: abort (); - break; } append_repeated_char (s2, char_to_repeat, s1->length - s2->length); -- 2.7.4
