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 0596C5A005E for ; Fri, 17 Feb 2023 15:29:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676644198; 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=0yNAlA8cKNcfvPPKbB95RHrWY2hjhOCpLj7oH/yu0bQ=; b=jVnGbLVL1sKxw9iVU1FiRPoNfpmJo4XHai5AHsafM/bY1Gbt9bhPm4VY5vaUAaFXyMM4hI yMzFT2MAo3cN+IEroQlYCTb3OmK4pD5iEIgSP0WhYMzaWDe+PUSY+Cl+x3jGd64p+8kyV3 sAy6d8jagy2Mc10u+B+F5Nth57WpFjY= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-487-vMieddupNA6atCXbY0fl_w-1; Fri, 17 Feb 2023 09:29:54 -0500 X-MC-Unique: vMieddupNA6atCXbY0fl_w-1 Received: by mail-qv1-f71.google.com with SMTP id c23-20020a056214071700b0053c23b938a0so396737qvz.17 for ; Fri, 17 Feb 2023 06:29:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:to:organization:from :references:cc:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0yNAlA8cKNcfvPPKbB95RHrWY2hjhOCpLj7oH/yu0bQ=; b=pH/O8/ZCer7yMfFhKf2qtHEli2TJz5HzXAWX0a8V/xBFiOv+EY2aHbnsBMQnDgctqD lWskyUn5EaFRRKE18WqUyMMA8LkC6gJPUqG3OtkUOt/A4MFue2WtE44VYObK025zMSeh QGVpdlFKxQjgLiWwwpJ3F4uBR6lOs3efo6ODYYhiUPFGj4ghtftKbKXLlGAz/UTHd+3P DW0Wbh7e0fFRW2SkmczVIr0xuQsfzfYlhiXIB61vdKVbMd4Bbhiyv3rsF00wxuqzx8d0 PMliU4CnD4Wb2f2se+Nx24j/OlxhOvpyVJSOboySthvBFxw4WtV7jweF12kAf2njLLI9 t48Q== X-Gm-Message-State: AO0yUKXMnIRo+IzXPzVn4z7PrZwFwQojAXj06EYuqiyh1Re/i+GU2Nz8 ssLb1P3EeMU+Oo9Wx4L+gWNqjx67uE+cRIlWS5TfJ3wr4j6Gx+2qd9TQSt+cUK2DkiwhTp59/I8 bZrLm4vtHorSBt+vZpf+OojhUeCo0yfob0/zpgVZdFzua1VlR0CnOAA/d9c3+Kmn4xA== X-Received: by 2002:a05:6214:508d:b0:56e:a90d:8e0f with SMTP id kk13-20020a056214508d00b0056ea90d8e0fmr653842qvb.41.1676644193369; Fri, 17 Feb 2023 06:29:53 -0800 (PST) X-Google-Smtp-Source: AK7set/RduVelzClTqaQaebU5KGbF8cnFvchDkYW9lEeLvmKEu7ptp22NteODEQgi1cdBIy6sxnGgw== X-Received: by 2002:a05:6214:508d:b0:56e:a90d:8e0f with SMTP id kk13-20020a056214508d00b0056ea90d8e0fmr653795qvb.41.1676644192934; Fri, 17 Feb 2023 06:29:52 -0800 (PST) Received: from ?IPV6:2600:8805:3a00:3:3b4f:6d3c:92c4:a5c7? ([2600:8805:3a00:3:3b4f:6d3c:92c4:a5c7]) by smtp.gmail.com with ESMTPSA id q205-20020a3743d6000000b0073b75718428sm3329225qka.134.2023.02.17.06.29.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Feb 2023 06:29:52 -0800 (PST) Message-ID: <71dcfbb0-e317-9e73-fb8d-07955bbcc3c1@redhat.com> Date: Fri, 17 Feb 2023 09:29:51 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] conf, tap: Silence two false positive invalidFunctionArg from cppcheck References: <20230216182210.2290008-1-sbrivio@redhat.com> From: Laine Stump Organization: Red Hat To: passt-dev@passt.top In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: GYLUVFEYQS3LZBTCQ4CX6Z2ZO4EKXJAW X-Message-ID-Hash: GYLUVFEYQS3LZBTCQ4CX6Z2ZO4EKXJAW X-MailFrom: laine@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: David Gibson , Stefano Brivio 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 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? (and is there a "make check" target that I should have been running and haven't?) 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. > >> --- >> conf.c | 3 +++ >> tap.c | 6 +++++- >> 2 files changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/conf.c b/conf.c >> index 675d961..5426c9b 100644 >> --- a/conf.c >> +++ b/conf.c >> @@ -1036,6 +1036,9 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid) >> if ((fd = open("/proc/self/uid_map", O_RDONLY | O_CLOEXEC)) < 0) { >> die("Can't determine if we're in init namespace: %s", >> strerror(errno)); >> + >> + /* Silence cppcheck's invalidFunctionArg for 'fd' in read() */ >> + return; >> } >> >> if (read(fd, buf, BUFSIZ) != sizeof(root_uid_map) || >> diff --git a/tap.c b/tap.c >> index 88eed88..d6f962e 100644 >> --- a/tap.c >> +++ b/tap.c >> @@ -1037,9 +1037,13 @@ static void tap_sock_unix_init(struct ctx *c) >> snprintf(path, UNIX_PATH_MAX - 1, UNIX_SOCK_PATH, i); >> >> ex = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); >> - if (ex < 0) >> + if (ex < 0) { >> die("UNIX domain socket check: %s", strerror(errno)); >> >> + /* Silence cppcheck's invalidFunctionArg for 'ex' */ >> + return; >> + } >> + >> ret = connect(ex, (const struct sockaddr *)&addr, sizeof(addr)); >> if (!ret || (errno != ENOENT && errno != ECONNREFUSED && >> errno != EACCES)) { >