From patchwork Mon Feb 27 14:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 657048 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2376386wrb; Mon, 27 Feb 2023 06:18:53 -0800 (PST) X-Google-Smtp-Source: AK7set98tWl2VTLzTq1W4G0YBTiHXDwf1DWRSaUb67QEOT1vVrVHVUU1fE32JC62zF/GFQTle9AW X-Received: by 2002:ac8:7d52:0:b0:3b8:4729:8225 with SMTP id h18-20020ac87d52000000b003b847298225mr31200048qtb.9.1677507533615; Mon, 27 Feb 2023 06:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677507533; cv=none; d=google.com; s=arc-20160816; b=Vyodz6bPNfJx7FaTKg6AqWlVZuv7xbtS9bYInFMOALFzOEC/GTglujgFH/nWuv7Qxp QW88wemxBxYpJN4+ZJf/LVJ9y+Q9P0dnaj9KGSDTNLn7wn9RM0Q7AoJ6S0IODgVlgEcc Qd1nGovnsetNXo/crYBeccRC47E8xvWLdALgoZoEMmpkaieHxjrdnVLkqT39Tk9qSnLB ZwFPFrLidX4vGdgPeNeuw9p+4icfXdiX8c9S9whqdtBxYGHpy5PTiQ2S3hY9qeO3+uiI vkRCpu51s1OHule4RpTJv2IQY0grT9KtonJHu3UsGFsMyA0Ci9A8OvfK0KqOhJskzWbe beJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9i8Ap7rsoDJGC5IE6sGz5Ob3MAuQT6Rsd3pA6gNBUDI=; b=QAv5iyWEOqpuscr6R1ZIfM++7NBR82smhH67eDozS6L4ygGFa0Awsr06KPAKDSTbku 3VFLf3wZAcauCkFxE+iO8zk6ifNM5PE1VlbtlkDoG9vfTRVjxa0v9fQ0ie2OuKJNdy95 v6Fs7hIsUU6DvVoircFElpmD+J8qTQtHwKLUXgrGojZzTL6dwe10Wq3peWSK93WPUAsZ e/gvxXHVjTh0AOxM+1URbSbIJ7+gcw906wOJO+lRVxaG8Vv4LLuymyTvp83W0hKNl/85 GJuBioGVRjHy4BdUUiIBMuusULQdeQEibwm87B1Aac7Csj312ak/Vqf8Ft2mfPw1ezBr vDpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WpkHBP5v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bm18-20020a05620a199200b0073ede8b345dsi6202634qkb.642.2023.02.27.06.18.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 06:18:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WpkHBP5v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWeCx-0006o3-KW; Mon, 27 Feb 2023 09:10:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWeCa-0006Yb-6n for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:10:06 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWeCY-0000fj-BW for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:10:03 -0500 Received: by mail-wm1-x32d.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so3407538wmq.1 for ; Mon, 27 Feb 2023 06:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9i8Ap7rsoDJGC5IE6sGz5Ob3MAuQT6Rsd3pA6gNBUDI=; b=WpkHBP5vu/Eg1TybTsaiNo8cESIRxpz5CEo0UI/UChm/dmf5THZRbF7F8aCgNliPAp OGjcfTT14P4FJXtfax94Wzlmn+vpVBtRnriRchNKhL11kE20RJBRmSOEMWgx4TnDEfQZ YaXCI+ga7QXMiIZXUbV2o24KeE7UCPV+yv0sOGc4YvSXcbu9Jh0K1wZFWZ5eHgcyETAG cwfXtmTVOhNn3hQf5vA4/4to8Cop1jJ9VeVjFtSPq0CCRPcFSuLyFBoGq5B1vFAvqx0d ekwNBnfIkP70PhelPvyC+zu2OqUQQ6ZUDG2fNWkK7rQhE0l8k3bPOpaao2u98D3Lf36W zLxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9i8Ap7rsoDJGC5IE6sGz5Ob3MAuQT6Rsd3pA6gNBUDI=; b=jZLM0xCGqgfqRzc2mFGOnLk4R5jz8jp4CIRtkCOp0NEamx7xMacjGliYRwHPdOAoU3 uom4TA2GF3v/OU90aDZwh2AU6Hz2IlxgSLyHtGB61ZHRw7o85qLRO4NAy4IVodNOr9wG 3LBmZ6RFJTkTn1x1qUTRRwqRjPfP0Qvev23Bl9F/whHEanoX144lweYmtBAnlIR53k+H hZK7jTYKQXePH6M9xdekPRPYZjjUQYCb2WgtvnBGE/3bMJKvnwoB606QA8U3eL8l6iv9 kySa7n/EWoy/STAPeqZ1rzp5hohKdVwaGxcMOJsr4hK6A6VZ4F5xAqzjuGvc3FminB41 9RVg== X-Gm-Message-State: AO0yUKWPSFmxnIGUppCg85wzJkcgt6eVAPP8YCUsySrmHQN0KoOEgvQT 4tgtbuTI9t4Pdd0yt77F5MyD8O6fGz+OnivQ X-Received: by 2002:a05:600c:492a:b0:3dc:42d2:aee4 with SMTP id f42-20020a05600c492a00b003dc42d2aee4mr12956427wmp.25.1677507000532; Mon, 27 Feb 2023 06:10:00 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id h8-20020adff188000000b002c54241b4fesm7121983wro.80.2023.02.27.06.09.59 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Feb 2023 06:10:00 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 095/126] scripts/checkpatch.pl: Do not allow assert(0) Date: Mon, 27 Feb 2023 15:01:42 +0100 Message-Id: <20230227140213.35084-86-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230227140213.35084-1-philmd@linaro.org> References: <20230227140213.35084-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since commit 262a69f428 ("osdep.h: Prohibit disabling assert() in supported builds") we can not build QEMU with NDEBUG (or G_DISABLE_ASSERT) defined, thus 'assert(0)' always aborts QEMU. However some static analyzers / compilers doesn't notice NDEBUG can't be defined and emit warnings if code is used after an 'assert(0)' call. Apparently such compiler isn't as clever with G_DISABLE_ASSERT, so we can silent these warnings by using g_assert_not_reached() which is easier to read anyway. In order to avoid these annoying warnings, add a checkpatch rule to prohibit 'assert(0)'. Suggest using g_assert_not_reached() instead. For example when reverting the previous patch we get: ERROR: use g_assert_not_reached() instead of assert(0) #21: FILE: target/ppc/dfp_helper.c:124: + assert(0); /* cannot get here */ ERROR: use g_assert_not_reached() instead of assert(0) #30: FILE: target/ppc/dfp_helper.c:141: + assert(0); /* cannot get here */ total: 2 errors, 0 warnings, 16 lines checked Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230221232520.14480-3-philmd@linaro.org> --- scripts/checkpatch.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6ecabfb2b5..d768171dcf 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2982,6 +2982,9 @@ sub process { if ($line =~ /\bsysconf\(_SC_PAGESIZE\)/) { ERROR("use qemu_real_host_page_size() instead of sysconf(_SC_PAGESIZE)\n" . $herecurr); } + if ($line =~ /\b(g_)?assert\(0\)/) { + ERROR("use g_assert_not_reached() instead of assert(0)\n" . $herecurr); + } my $non_exit_glib_asserts = qr{g_assert_cmpstr| g_assert_cmpint| g_assert_cmpuint|