From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH] tap: Avoid bogus missingReturn cppcheck warning in tap_l2_max_len()
Date: Thu, 15 May 2025 18:05:01 +0200 [thread overview]
Message-ID: <20250515160501.2636220-1-sbrivio@redhat.com> (raw)
Cppcheck 2.14.2 on Alpine Linux (musl) says that:
tap.c:111:19: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
switch (c->mode) {
^
This exit path is not reachable because we ASSERT(0) after the switch,
but for some reason cppcheck doesn't see this with musl headers. Hide
the warning with a redundant return statement.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tap.c b/tap.c
index d630f6d..6db5d88 100644
--- a/tap.c
+++ b/tap.c
@@ -118,6 +118,8 @@ unsigned long tap_l2_max_len(const struct ctx *c)
}
/* NOLINTEND(bugprone-branch-clone) */
ASSERT(0);
+
+ return 0; /* Unreachable, for cppcheck's sake */
}
/**
--
2.43.0
next reply other threads:[~2025-05-15 16:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 16:05 Stefano Brivio [this message]
2025-05-16 7:25 ` David Gibson
2025-05-16 16:26 ` Stefano Brivio
2025-05-17 10:29 ` David Gibson
2025-05-19 7:27 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250515160501.2636220-1-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).