The -Wsometimes-uninitialized warning seems useful (see [1]) and is only triggered in two other places currently. Similar code currently uses programming_error; adding the __noreturn__ attribute to that function and calling it in these cases avoids the warning.
I wonder if using unreachable() might not be more appropriate, but it's not currently used anywhere in bash. [1] https://lists.gnu.org/r/bug-bash/2025-11/msg00067.html --- error.h | 2 +- pathexp.c | 2 +- redir.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/error.h b/error.h index db0972bc..300e088c 100644 --- a/error.h +++ b/error.h @@ -30,7 +30,7 @@ extern char *get_name_for_error (void); extern void file_error (const char *); /* Report a programmer's error, and abort. Pass REASON, and ARG1 ... ARG5. */ -extern void programming_error (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +extern void programming_error (const char *, ...) __attribute__((__format__ (printf, 1, 2))) __attribute__((__noreturn__)); /* General error reporting. Pass FORMAT and ARG1 ... ARG5. */ extern void report_error (const char *, ...) __attribute__((__format__ (printf, 1, 2))); diff --git a/pathexp.c b/pathexp.c index 1692e054..1ccf8039 100644 --- a/pathexp.c +++ b/pathexp.c @@ -903,7 +903,7 @@ globsort_sortarray (struct globsort_t *garray, size_t len) sortfunc = (QSFUNC *)globsort_numericcmp; break; default: - internal_error (_("invalid glob sort type")); + programming_error (_("invalid glob sort type")); break; } diff --git a/redir.c b/redir.c index 3083a163..9b3c3310 100644 --- a/redir.c +++ b/redir.c @@ -816,6 +816,7 @@ do_redirection_internal (REDIRECT *redirect, int flags, char **fnp) new_redirect = make_redirection (sd, r_move_output, rd, rflags); break; default: + programming_error ("do_redirection_internal"); break; /* shut up gcc */ } } -- 2.52.0
