* [PATCH] flow: Reduce scope of type_or_state in flow_log__()
@ 2026-11-20 0:15 Jon Maloy
2026-11-22 22:15 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Jon Maloy @ 2026-11-20 0:15 UTC (permalink / raw)
To: sbrivio, david, jmaloy, passt-dev
Since commit bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow
logging functions"), type_or_state is only used in the branch handling
non-NULL flows, and cppcheck points out that its scope can be reduced,
causing 'make cppcheck' to fail. We do that here.
Fixes: bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow logging functions")
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
flow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/flow.c b/flow.c
index 27a24a4c..f9fbaefe 100644
--- a/flow.c
+++ b/flow.c
@@ -286,7 +286,6 @@ int flowside_connect(const struct ctx *c, int s,
void flow_log__(const struct flow_common *f, int pri, bool perror, bool details,
enum flow_state state, const char *fmt, ...)
{
- const char *type_or_state;
int errno_ = errno;
char msg[BUFSIZ];
va_list args;
@@ -299,6 +298,8 @@ void flow_log__(const struct flow_common *f, int pri, bool perror, bool details,
logmsg(!perror, false, pri, "Flow: not found, error: %s", msg);
details = false;
} else {
+ const char *type_or_state;
+
/* Show type if it's set, otherwise the state */
if (f->state < FLOW_STATE_TYPED)
type_or_state = FLOW_STATE(f);
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] flow: Reduce scope of type_or_state in flow_log__()
2026-11-20 0:15 [PATCH] flow: Reduce scope of type_or_state in flow_log__() Jon Maloy
@ 2026-11-22 22:15 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2026-11-22 22:15 UTC (permalink / raw)
To: Jon Maloy; +Cc: david, passt-dev
On Thu, 19 Nov 2026 19:15:29 -0500
Jon Maloy <jmaloy@redhat.com> wrote:
> Since commit bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow
> logging functions"), type_or_state is only used in the branch handling
> non-NULL flows, and cppcheck points out that its scope can be reduced,
> causing 'make cppcheck' to fail. We do that here.
>
> Fixes: bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow logging functions")
> Signed-off-by: Jon Maloy <jmaloy@redhat.com>
See:
https://archives.passt.top/passt-dev/20261119124916.3150605-1-lvivier@redhat.com/
I applied that one with this Fixes: tag even though the Cppcheck version
I'm using didn't report this, but I would still agree that it's a fix
for most people.
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-22 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 0:15 [PATCH] flow: Reduce scope of type_or_state in flow_log__() Jon Maloy
2026-11-22 22:15 ` Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).