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.133.124]) by passt.top (Postfix) with ESMTP id 3797F5A005E for ; Fri, 17 Feb 2023 15:37:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676644642; 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=Q2WGv1zyb5NKU1vJT0/hTRCQUHt2AGLWoUbRorQM1tQ=; b=d7FHbh5+PSdFOduxJAuo1nQzpI+FefrzA6Di65cacZAwgXg+1UPT9zQ8JFyxuugf4/1OK2 e9Quxf2lBZNQ70BiLJcDdq0roCm814MMaN/HQK2Qbn5pcRLZjPqZcfFkuf8GWTDpxht65s +RiByfpAZyg+oVhoOzMvmv8+NJyy/TY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-482-vnsL9AWaN--JiMhRfc8DDg-1; Fri, 17 Feb 2023 09:37:19 -0500 X-MC-Unique: vnsL9AWaN--JiMhRfc8DDg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F3A13814581; Fri, 17 Feb 2023 14:37:19 +0000 (UTC) Received: from maya.cloud.tilaa.com (unknown [10.33.32.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6477C2026D4B; Fri, 17 Feb 2023 14:37:18 +0000 (UTC) Date: Fri, 17 Feb 2023 15:37:16 +0100 From: Stefano Brivio To: Laine Stump Subject: Re: [PATCH] conf, tap: Silence two false positive invalidFunctionArg from cppcheck Message-ID: <20230217153716.6017cdc4@elisabeth> In-Reply-To: <71dcfbb0-e317-9e73-fb8d-07955bbcc3c1@redhat.com> References: <20230216182210.2290008-1-sbrivio@redhat.com> <71dcfbb0-e317-9e73-fb8d-07955bbcc3c1@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: E4G6NFZZM4USWR4COVKVQDVLDHTVAUBP X-Message-ID-Hash: E4G6NFZZM4USWR4COVKVQDVLDHTVAUBP 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, David Gibson X-Mailman-Version: 3.3.3 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 Fri, 17 Feb 2023 09:29:51 -0500 Laine Stump wrote: > On 2/16/23 5:53 PM, David Gibson wrote: > > On Thu, Feb 16, 2023 at 07:22:10PM +0100, Stefano Brivio wrote: > >> The newly introduced die() calls exit(), but cppcheck doesn't see it > >> and warns about possibly invalid arguments used after the check which > >> triggers die(). Add return statements to silence the warnings. > >> > >> Signed-off-by: Stefano Brivio > > > > Oof, that's super ugly. Any chance that cppcheck will recognize the > > ((noreturn)) attribute if we added it to die()? > > Why is this only a problem in these two files? Because that's where we would use a variable as a system call argument, if the check possibly leading to die() didn't exist. > (and is there a "make check" target that I should have been running and > haven't?) make cppcheck, make clang-tidy, and possibly the tests (see test/README.md) -- but it's not mandatory, especially if you're an occasional contributor, I'm running them anyway. > Requiring an extra "return" after die() kind of removes the advantage of > using it over err(). :-/ If we have to do that, it would be more > straightforward to just use err() followed by exit() directly. We don't have to (see the rest of this thread): we could simply define die() as err() with an additional return statement *outside* err() itself, instead of passing 'doexit' as parameter. Probably something like: do { err(...) exit(EXIT_FAILURE); return; } while (0) -- Stefano