From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=h0Z4bakd; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 87C125A0280 for ; Fri, 06 Jun 2025 12:06:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749204379; 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=Q/Y68+NBgoGhNZ/iyNsKhDa79C3E4GOrrGnldsJmQoM=; b=h0Z4bakdWdUGCrTdKC8BA3IKHZPdtLuFFRP0PAjfR5nCTEX4qLnkH1D7AKipNtDawpmRpd pbbvEDU4Et9CF3nMRmH80+R9/S2VKwVT3brSmFO79Xor6hASiYOmmrcwygxuJVmIpuPRNf /53qxDkclQ6IVjt5vheulmrRlsLc7WE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-470-6qxgOV7kMliHHndOzuz-qw-1; Fri, 06 Jun 2025 06:06:18 -0400 X-MC-Unique: 6qxgOV7kMliHHndOzuz-qw-1 X-Mimecast-MFC-AGG-ID: 6qxgOV7kMliHHndOzuz-qw_1749204377 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43eea5a5d80so10598235e9.1 for ; Fri, 06 Jun 2025 03:06:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749204376; x=1749809176; 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=Q/Y68+NBgoGhNZ/iyNsKhDa79C3E4GOrrGnldsJmQoM=; b=lFP31MZxrdpRep+Ra8XEDoZ/H3h7Pn8KgdT3JKrxBEvzgfKqjCenFuxzjW2vA9pR7+ 9nxe1wl5FggsZ23Ex99JGbZoHCW4B8gCjUsBrX/RB4tRWz9IhaSKNIIod5BKlYdOiv0n CTECvDLlC+fkM9ebng1pHqDgZUiar4nSWCzDrfEpcefJw1EAiIU6wKlhbOyt3CNEcP3w sSFQ6O9tCirQ125hTmtRioez+x4Lew39R272mvh39p0Dn33ZXQ/mDpxukZQ8KtSTOioq 7eKbcnNSWU1RyfKzH5hpEXxWLpOGoTyc5WBvUiyMVJ76BxeEFF+vITfR9l+qdErCMpkC kdqg== X-Forwarded-Encrypted: i=1; AJvYcCVMujfTrl4myhdMNch2+9hcol7Cv4IFhs1LJNMcvaR4/Lbom2ZmfPlSa7vO4v1ub24Ogp1kZo/roY4=@passt.top X-Gm-Message-State: AOJu0YxQFjckwQR6qfiajMd8bFak6CYOlrMy42jrJZkCnzuzTc0kK+Hl Lvx+r3S9dsRQt8PCnBYuE2prZj5bOkPSNuv1bDmjT/SRvwSNTBLvfpMfMcWxgeAqWllSNiy00R9 DyfgMuygWn0sgiJL/vGOCdC+h5ZJTxEC0mSWbZTeyJ1s2DJBzb5FpsP2zVJB8URQCxrQbtXmcrO 2SHP9O9HGjW1L4vwP+9ehFT/HduCZGTnergsVe X-Gm-Gg: ASbGncsYewH/4jwGezQpbx91pYLlSS7bTC7n9b5AZrf+K4iWX+TBwnGwgq60/1aDDxW 8YkWEwzDmEfO1ER49rYhLTSUadyNOH9/tsvvHYrwXCsjnvlbgcIqghq+ruWc24zDd1bUcVMjEgi I9xBf/kFF8QHsKj3w5iCxEeceuOJoGJlQioYkIShR9PIc8RzUYhwljtHkZpNzlo7qCt6f15S3vg zLWSzpqqiQvGl8HH1FbjPhSOYh9qFpBWjjbVZtccvzVdlF26yZoI4JWQPbGu8iriLvyPAlFGtRn 5pDvXuOoUHM4HQxMZ/b0WE0= X-Received: by 2002:a5d:5f8c:0:b0:3a4:e665:ca5 with SMTP id ffacd0b85a97d-3a531883d8dmr2733111f8f.23.1749204376664; Fri, 06 Jun 2025 03:06:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyRlS9QyAobbuMnj6I/nzB7BoPC9n0wBd+hVvBXjimQNlWNqcEv7PDM4QmRtrSbUUZ0gkqHQ== X-Received: by 2002:a5d:5f8c:0:b0:3a4:e665:ca5 with SMTP id ffacd0b85a97d-3a531883d8dmr2733067f8f.23.1749204376148; Fri, 06 Jun 2025 03:06:16 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45213709611sm18901815e9.24.2025.06.06.03.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jun 2025 03:06:15 -0700 (PDT) Date: Fri, 6 Jun 2025 12:06:14 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: conf: flush stdout before early exit Message-ID: <20250606120614.0ce4160f@elisabeth> In-Reply-To: <20250604170036.050e638b@elisabeth> References: <20250529170858.185281-1-jmaloy@redhat.com> <20250604170036.050e638b@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jHlvstsps6V-Lig8v7iASK5FDYrbCFipQCkcCNcT8Ds_1749204377 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: CZRIPPTMGBG4KHRYR6FJDQBMFL6FKRC6 X-Message-ID-Hash: CZRIPPTMGBG4KHRYR6FJDQBMFL6FKRC6 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: dgibson@redhat.com, passt-dev@passt.top 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, 4 Jun 2025 17:00:36 +0200 Stefano Brivio wrote: > On Thu, 29 May 2025 13:08:58 -0400 > Jon Maloy wrote: > > > Before doing an early exit any contents of stdout is normally flushed. > > This doesn't happen when the output goes into a pipe and we return with > > _exit(). We now add an explicit flush in such cases. > > > > Fixes: d0006fa784a7 ("treewide: use _exit() over exit()") > > > > Signed-off-by: Jon Maloy > > --- > > conf.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/conf.c b/conf.c > > index a6d7e22..a1d55a3 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -975,6 +975,7 @@ static void usage(const char *name, FILE *f, int status) > > " SPEC is as described for TCP above\n" > > " default: none\n"); > > > > + fflush(f); > > _exit(status); > > > > pasta_opts: > > @@ -1029,6 +1030,7 @@ pasta_opts: > > " --ns-mac-addr ADDR Set MAC address on tap interface\n" > > " --no-splice Disable inbound socket splicing\n"); > > > > + fflush(f); > > _exit(status); > > } > > > > @@ -1594,6 +1596,7 @@ void conf(struct ctx *c, int argc, char **argv) > > FPRINTF(stdout, > > c->mode == MODE_PASTA ? "pasta " : "passt "); > > FPRINTF(stdout, VERSION_BLOB); > > + fflush(stdout); > > I was about to apply this, but clang-tidy now complains: > > /home/sbrivio/passt/conf.c:978:2: error: the value returned by this function should not be disregarded; neglecting it may lead to errors [cert-err33-c,-warnings-as-errors] > 978 | fflush(f); > | ^~~~~~~~~ > /home/sbrivio/passt/conf.c:978:2: note: cast the expression to void to silence this warning > /home/sbrivio/passt/conf.c:1033:2: error: the value returned by this function should not be disregarded; neglecting it may lead to errors [cert-err33-c,-warnings-as-errors] > 1033 | fflush(f); > | ^~~~~~~~~ > /home/sbrivio/passt/conf.c:1033:2: note: cast the expression to void to silence this warning > /home/sbrivio/passt/conf.c:1599:4: error: the value returned by this function should not be disregarded; neglecting it may lead to errors [cert-err33-c,-warnings-as-errors] > 1599 | fflush(stdout); > | ^~~~~~~~~~~~~~ > /home/sbrivio/passt/conf.c:1599:4: note: cast the expression to void to silence this warning > > I don't see any sensible way to use the return value from fflush(), > because, of course, if 'f' or stdout is not a valid stream or isn't open > for writing (that's the only defined error for fflush()), it doesn't > make sense to even try and print a warning to stdout or stderr. > > So I would rather suppress the warning as suggested by clang-tidy > (casting to void instead of a specific clang-tidy suppression, just in > case other static checkers start complaining as well). I can do this on > merge if you're fine with it. I took that as a yes and went ahead with it, thanks for the fix! -- Stefano