From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=CGavISIZ; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5E07E5A061D for ; Wed, 06 Nov 2024 07:54:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730876064; bh=4BXAVapt2zfvEbsPg9Qop1wmfklvk/utIdariyLvObg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CGavISIZrHrYx0+oL2kaVXFRjPdv5btv/tDvK4MefdxDV6614jv1V51SNHLvF5Fil uG3u1Rffg+LbGL5apEuWWF11KH3oxVLp+MabMPBs8eRDieECH2q4H7ASWaG7HTeffX FmXylXujS2EjN9XiWNMSpeZ/0XixQkmOvbrNzw+MoGEG3wcb/qWzrEL/G9c00r+R5S ePvh/Es9MzPGxmddM2nK8t1AVg+GtEi6pZtVLFdYFzC3UT1oRG59B4YwEc8IRuRqTJ 3+pr7tp9zFzkVMizJN5gWX1oOhBELdb9n+MZH+AkZZaoyB4WR+KSeN/WrwqO8A/K+k bUwMUP56XIT5w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Xjwt819vhz4xG8; Wed, 6 Nov 2024 17:54:24 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 7/8] util: Work around cppcheck bug 6936 Date: Wed, 6 Nov 2024 17:54:20 +1100 Message-ID: <20241106065421.2568179-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106065421.2568179-1-david@gibson.dropbear.id.au> References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FB2EKTUYXDKHKNNZ5W3I3JO2WDMZ3GXO X-Message-ID-Hash: FB2EKTUYXDKHKNNZ5W3I3JO2WDMZ3GXO X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: While experimenting with cppcheck options, I hit several false positives caused by this bug: https://trac.cppcheck.net/ticket/13227 Signed-off-by: David Gibson --- Makefile | 2 +- util.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cb91535..0ba85b4 100644 --- a/Makefile +++ b/Makefile @@ -183,5 +183,5 @@ cppcheck: $(PASST_SRCS) $(HEADERS) $(SYSTEM_INCLUDES:%=--suppress=unmatchedSuppression:%/*) \ --inline-suppr \ --suppress=unusedStructMember \ - $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \ + $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -D CPPCHECK_6936 \ $(PASST_SRCS) $(HEADERS) diff --git a/util.h b/util.h index fdc3af8..1a4dfd4 100644 --- a/util.h +++ b/util.h @@ -67,6 +67,15 @@ #define STRINGIFY(x) #x #define STR(x) STRINGIFY(x) +#ifdef CPPCHECK_6936 +/* Some cppcheck versions get confused by aborts inside a loop, causing + * it to give false positive uninitialised variable warnings later in + * the function, because it doesn't realise the non-initialising path + * already exited. See https://trac.cppcheck.net/ticket/13227 + */ +#define ASSERT(expr) \ + ((expr) ? (void)0 : abort()) +#else #define ASSERT(expr) \ do { \ if (!(expr)) { \ @@ -78,6 +87,7 @@ abort(); \ } \ } while (0) +#endif #ifdef P_tmpdir #define TMPDIR P_tmpdir -- 2.47.0