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=AgAfy+tj; 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 42C885A0282 for ; Wed, 04 Jun 2025 17:00:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749049243; 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=MaDS0eaDomMYlo9eyHle29DlRvPAXbWk8FlQYucslxc=; b=AgAfy+tjxmkbuVrm1Z6WZbm4Pq1JQ4XhFT3GA59qed9vg9DVFulxzh9LS6151FHk5ZEFPR Sag4DVq9lcaoerwzQ4KFh3SWqDUZ4FvtMtFdlg4Rtw9gO/OJjGKnexLKt6SN3SqFVCG2BI DZ8BneP/V1GlozqwI1BY4/UwDsjTp7Q= 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-126-1HJW6tNVM961MibsrQ5qMQ-1; Wed, 04 Jun 2025 11:00:41 -0400 X-MC-Unique: 1HJW6tNVM961MibsrQ5qMQ-1 X-Mimecast-MFC-AGG-ID: 1HJW6tNVM961MibsrQ5qMQ_1749049241 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-442e0e6eb84so46151125e9.0 for ; Wed, 04 Jun 2025 08:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749049240; x=1749654040; 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=MaDS0eaDomMYlo9eyHle29DlRvPAXbWk8FlQYucslxc=; b=mGDMJ6DU7u8N/plnBc+1DdiF/M1r9Dd6E5AIiX11TwL1H6TR4uvimxye8568Da9WmA ZDn48OEt2EMFHa859Maunm69kie2eNNOho7CO3rSdob3onaKb1btE0C3WhJwwNtV+CFC HYgxD5SnEfNhNqo2hpgw8Y/Gy0z/ODnp1hoPE9EU8UJUPU5B/eDQHbaUWEqa1wlB0ek4 hmvblNTJzddbLQdhFkeU3OTXg6VKCI6PiyL2+liKWSn9/BEKkpWK2ugcj6RN5tsDz6Ca cPMpeAw7chxWPobk1TksO+RpNTGB3VVII4zD+V+5XpYIWYGtf+1/LOTqTpxufkGWR0tv VW7A== X-Forwarded-Encrypted: i=1; AJvYcCVk5z9J11h7tirB7vRaROcgqkmrrpfPokMkEMezyhrNTXYb3EObES4Iw75xepiJfzjOsvB00EH+vsw=@passt.top X-Gm-Message-State: AOJu0YwVM9XYIq5zpWYgKUYmJQarst6Eq2re77wz7qDZk7yjNKWYWf1w Sn1sEqRDC99URWk0x5Xmtw8cXptKfCEq8BOK11DWhMsbiH3nCvpLfh3XrXglWbPUwRcnddRB96/ eoBj91ckW1O8GvrQ7ZpytU7j4Z5ZpQUBA5xtV1Q3ZMbilRoxdOSjA2bqx4Q+sOqls6i9ngE+0/j 10JnWE8ZOEJhhW7TIyJeyGG9JrdQXeHNa/15TS X-Gm-Gg: ASbGnctX3G+U4yMoIYcixfOunvoOJXRYab7wTU5xtJZSpZXpUbFSTY6vFvTRVp//XDs 5zcW4+ScedrDb0QU8M2sSgFg9ivmwX930UJJN0SKjKK9N7MwOpeL/cNg3r+r+09UEUqpGuVQBbY j7TZgWBCGGaebNdwQJ1yK1z8fum+q4OUhAXn35+1ZMYcl5gDd1m9Osj2J6icNLflz16PVjWqnnn tp6tOTBFJjWImidgkeDp7Rp3Jue2pYXrUoPYR5GPRwS1jWXYnrkuOaAA185luWbA5So3TL6CRaj CbfJOScguE8MVVJPUZu656m0izSRIAaNWX/evGJnAVlPACsfe6I= X-Received: by 2002:a05:600c:35c3:b0:43c:fc04:6d35 with SMTP id 5b1f17b1804b1-451f0a6494amr32485745e9.4.1749049239988; Wed, 04 Jun 2025 08:00:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeyGg42Ok3ZnFplyd+A+tOPytqBYPF0Saxk8DBS+eDohmrbEcNh6kSglU1d49Lz/fnzssXag== X-Received: by 2002:a05:600c:35c3:b0:43c:fc04:6d35 with SMTP id 5b1f17b1804b1-451f0a6494amr32483795e9.4.1749049238402; Wed, 04 Jun 2025 08:00:38 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-451f82878casm39735e9.1.2025.06.04.08.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jun 2025 08:00:37 -0700 (PDT) Date: Wed, 4 Jun 2025 17:00:36 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: conf: flush stdout before early exit Message-ID: <20250604170036.050e638b@elisabeth> In-Reply-To: <20250529170858.185281-1-jmaloy@redhat.com> References: <20250529170858.185281-1-jmaloy@redhat.com> 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: A-peJ-XgtGC5mKrsbu6yW4oQjQZfGXzD9_7OCb8J5TA_1749049241 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: XADLGTJEKLMXBI4ZJVQ32FZDLEI2I42O X-Message-ID-Hash: XADLGTJEKLMXBI4ZJVQ32FZDLEI2I42O 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 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. -- Stefano