public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Hayato Kiwata <dev@haytok.jp>
To: passt-dev@passt.top
Cc: Hayato Kiwata <dev@haytok.jp>, Stefano Brivio <sbrivio@redhat.com>
Subject: [PATCH] pesto: Drop exit_status, use status to select the exit code
Date: Wed, 25 Nov 2026 22:38:07 +0900	[thread overview]
Message-ID: <20261125133807.26349-1-dev@haytok.jp> (raw)

Commit 885c39e8b999 ("conf, pesto: Notify client of the result of rule
updates") added an exit_status variable to exit with a non-zero status
if the server reports a failure. However, the status read from the
server already tells us whether the update failed.

Drop exit_status, broaden the scope of status, and select the exit code
from it when we call exit(). Initialize status to PESTO_STATUS_OK, since
it is not read from the server when pesto only shows the current rules
or the server uses a protocol version older than 3.

Link: https://archives.passt.top/passt-dev/20261120235844.75da1afa@elisabeth/
Suggested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Hayato Kiwata <dev@haytok.jp>
---
 pesto.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/pesto.c b/pesto.c
index 03edc29..fe5a536 100644
--- a/pesto.c
+++ b/pesto.c
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
 	struct sockaddr_un a = { AF_UNIX, "" };
 	struct configuration conf = { 0 };
 	bool update = false, show = false;
-	int exit_status = EXIT_SUCCESS;
+	uint8_t status = PESTO_STATUS_OK;
 	struct pesto_hello hello;
 	struct sock_fprog prog;
 	int optname, ret, s;
@@ -515,8 +515,6 @@ int main(int argc, char **argv)
 	send_conf(s, &conf);
 
 	if (s_version >= PESTO_VERSION_STATUS) {
-		uint8_t status;
-
 		if (read_u8(s, &status) < 0)
 			die_perror("Couldn't read configuration status");
 
@@ -524,16 +522,13 @@ int main(int argc, char **argv)
 		case PESTO_STATUS_OK:
 			break;
 		case PESTO_STATUS_ROLLBACK:
-			exit_status = EXIT_FAILURE;
 			warn("Failed to apply new rules, old rules restored");
 			break;
 		case PESTO_STATUS_FAILED:
-			exit_status = EXIT_FAILURE;
 			warn(
 "Failed to apply new rules, couldn't restore old ones");
 			break;
 		default:
-			exit_status = EXIT_FAILURE;
 			warn("Unknown configuration status %"PRIu8, status);
 		}
 	}
@@ -542,5 +537,5 @@ noupdate:
 	if (shutdown(s, SHUT_RDWR) < 0 || close(s) < 0)
 		die_perror("Error shutting down control socket");
 
-	exit(exit_status);
+	exit(status == PESTO_STATUS_OK ? EXIT_SUCCESS : EXIT_FAILURE);
 }
-- 
2.50.1 (Apple Git-155)


                 reply	other threads:[~2026-11-25 13:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125133807.26349-1-dev@haytok.jp \
    --to=dev@haytok.jp \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).