From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 355175A0274 for ; Wed, 28 Feb 2024 07:24:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709101467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ftj4mUmTrqTAcPLqzpdpDyxTzLLuAJVFLz/pzBuY4Ls=; b=FKRUghTB+BDELK70ss2mrg2oYk4TfF2ALM2APVRjFtQFdaYRb+2uJ2RzBCn+uDR0XF2NyR WOZaMJ6FsBLx7QAf+BCZrcQFDK3fbPALk4BV1I0ygDwHYuYIcF8Zg1s73OATJHYB0/JOri ChgVNdrKwbNKguXExax5RJhPIbkg3VY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-QhGLAyREPVWNOMK0Os76jQ-1; Wed, 28 Feb 2024 01:24:22 -0500 X-MC-Unique: QhGLAyREPVWNOMK0Os76jQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a26f2da3c7bso343220366b.0 for ; Tue, 27 Feb 2024 22:24:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709101461; x=1709706261; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Ftj4mUmTrqTAcPLqzpdpDyxTzLLuAJVFLz/pzBuY4Ls=; b=A5/k9u7sd/+gs1NVqBd+3LJyH/JD97x8tNsrO7tPjjHTAfnn3SzC7WxpcDPYfj0SN+ Npmqr6k01Q+6VHc7vIwruJ9ohAMUPieppbeSIULtWA5pYYJP0GwrVzgxw1o3WlY9i5vt A3SdZcyi2Dvxz82M1BmHeMIhiA6dcvwbWv+RWjonpdFMHyoyc5EJQaoFlyqHNIlLufZL ONOkfpdOmx/seBUna3fQed2qEc+I97xqwz/pRDLhlOPYT7mir1Ng7GaWBvEaTw6jSkex I9FOHACCVUjnetV0b5OZNJuelEFLec7YVz4hGUl7p2QB7EqUcYR0TdT6AmFt7zVjRdfQ InMQ== X-Gm-Message-State: AOJu0YwGlewBXi8YM3ezyrGcKDxbFyMAtSCu0gLGSbZHxS3lSXB0zJ+f OuHurHDtK80G8rOUWsFI85pv06yWEa+P/U1NUE69v4fOQvNP4q/gWeOGqf06azHGCO7JJyU8w2j 4h3Z2MP2QHTcT3FhhvrBSJLiqKTIzNdUmVY9D9gQb8hHEDBniNw== X-Received: by 2002:a17:906:d0c5:b0:a43:7e63:69a2 with SMTP id bq5-20020a170906d0c500b00a437e6369a2mr4048429ejb.77.1709101461068; Tue, 27 Feb 2024 22:24:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdrK6UIdkjhU79jxXlttbTE6WXNhjAxqxPcNY6q6HA1eEv+1o1r9/YlZi9TRyo/UcbzYFoUw== X-Received: by 2002:a17:906:d0c5:b0:a43:7e63:69a2 with SMTP id bq5-20020a170906d0c500b00a437e6369a2mr4048417ejb.77.1709101460707; Tue, 27 Feb 2024 22:24:20 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id o27-20020a170906289b00b00a3f1cb81dc6sm1497168ejd.84.2024.02.27.22.24.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2024 22:24:20 -0800 (PST) Date: Wed, 28 Feb 2024 07:23:46 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] Makefile: check for cppcheck's --check-level option in cppcheck target Message-ID: <20240228072346.03571b60@elisabeth> In-Reply-To: References: <20240227162947.2442020-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: HITL3SXPYRJBU6FLH2CTI47ANXWKDFVR X-Message-ID-Hash: HITL3SXPYRJBU6FLH2CTI47ANXWKDFVR X-MailFrom: sbrivio@redhat.com 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: passt-dev@passt.top, Rahil Bhimjiani 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: On Wed, 28 Feb 2024 08:24:49 +1100 David Gibson wrote: > On Tue, Feb 27, 2024 at 05:29:47PM +0100, Stefano Brivio wrote: > > Don't run cppcheck to find out if the --check-level=exhaustive option > > is available, unless we're actually going to run cppcheck later. > > > > To avoid this, move this check under the cppcheck target, and > > implement it in shell script instead of using Makefile directives, > > because we can't easily implement conditionals in recipes. > > > > Reported-by: Rahil Bhimjiani > > Link: https://bugs.gentoo.org/920795 > > Fixes: 8640d62af719 ("cppcheck: Use "exhaustive" level checking when available") > > Signed-off-by: Stefano Brivio > > --- > > Makefile | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index af4fa87..75d0bf3 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -287,17 +287,17 @@ clang-tidy: $(SRCS) $(HEADERS) > > -config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \ > > --warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -DCLANG_TIDY_58992 > > > > -CPPCHECK_EXHAUSTIVE := > > -ifeq ($(shell cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; echo $$?),0) > > - CPPCHECK_EXHAUSTIVE += --check-level=exhaustive > > -endif > > - > > SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET)) > > ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) > > VER := $(shell $(CC) -dumpversion) > > SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include > > endif > > cppcheck: $(SRCS) $(HEADERS) > > + if cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; then \ > > + CPPCHECK_EXHAUSTIVE="--check-level=exhaustive"; \ > > + else \ > > + CPPCHECK_EXHAUSTIVE=; \ > > + fi; \ > > cppcheck --std=c11 --error-exitcode=1 --enable=all --force \ > > --inconclusive --library=posix --quiet \ > > $(CPPCHECK_EXHAUSTIVE) \ > > IIUC, this is essentially moving CPPCHECK_EXHAUSTIVE from a make > variable to a shell variable in the shell that make invokes. Which is > fine, but I believe $(CPPCHECK_EXHAUSTIVE) will only expand to a make > variable. To get the shell variable you'll need > $${CPPCHECK_EXHAUSTIVE}. I suspect as written, this will always > expand empty. Oops, you're right, I had only tested the negative case. Fixed in v2. -- Stefano