From f4a3d61a172039515b3b04f5fb8d8dddfb509af7 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Mon, 6 Apr 2026 16:07:56 +0100 Subject: [PATCH] Restructure the "monitor remaining side" part to avoid the need for a fallthrough in the case statement, getting rid of compiler warnings on CentOS 5, 6, and 7, and arguably making the code easier to follow. --- src/main/main.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index 76c00c6..7dcb377 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -572,12 +572,13 @@ x = 1; \ } /* Monitor the remaining side. */ - switch (opts->side) { - case PV_SIDE_NONE: - retcode = PV_ERROREXIT_MONITOR; - break; - case PV_SIDE_BOTH: - /* Use name1, format1 for the "in" side. */ + + /* + * In "both" mode, the remaining side is "in", so if two sets of + * name and/or format options were given, we need to switch to using + * the ones given first. + */ + if (PV_SIDE_BOTH == opts->side) { if (NULL != opts->name1) { pv_state_name_set(state, opts->name1); } @@ -586,12 +587,13 @@ x = 1; \ } /* Trigger a format reparse. */ pv_state_set_format_options(state, format_options); - /* Now monitor the "in" side, as the "out" monitor was spawned above. */ - /*@fallthrough@ */ - /* falling through as "out" is in another process (above). */ -#ifndef SPLINT - __attribute__((fallthrough)); -#endif + } + + switch (opts->side) { + case PV_SIDE_NONE: + retcode = PV_ERROREXIT_MONITOR; + break; + case PV_SIDE_BOTH: case PV_SIDE_IN: /* Close the read end of the "out" pipe. */ close_if_open(pipefd_cmd_out[0]);