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.

This commit is contained in:
Andrew Wood
2026-04-06 16:07:56 +01:00
parent e01e456825
commit f4a3d61a17
+14 -12
View File
@@ -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]);