From 259350229028c956fdd5d91c1a6092d4d90cf8a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Thu, 21 Sep 2023 18:48:49 +0100 Subject: [PATCH] build: avoid build failures on gcc <= 10, or clang On gcc 10 the following build failure occurs: "error: a label can only be part of a statement and a declaration is not a statement" This is because the current code is non standards conforming, but GCC >= 11 will compile it (even with the -Wpedantic option). This issue is tracked for GCC at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526 * src/tail.c (parse_options): Avoid a declaration after label, by using a surrounding block. --- src/tail.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tail.c b/src/tail.c index 904a76d019..4c3c7b5905 100644 --- a/src/tail.c +++ b/src/tail.c @@ -2208,11 +2208,13 @@ parse_options (int argc, char **argv, break; case PID_OPTION: - pid_t pid = - xdectoumax (optarg, 0, PID_T_MAX, "", _("invalid PID"), 0); - pids = xreallocarray (pids, nbpids + 1, sizeof (pid_t)); - pids[nbpids] = pid; - nbpids++; + { + pid_t pid = + xdectoumax (optarg, 0, PID_T_MAX, "", _("invalid PID"), 0); + pids = xreallocarray (pids, nbpids + 1, sizeof (pid_t)); + pids[nbpids] = pid; + nbpids++; + } break; case PRESUME_INPUT_PIPE_OPTION: -- 2.47.2