* [PATCH] pesto: Drop exit_status, use status to select the exit code
@ 2026-11-25 13:38 Hayato Kiwata
0 siblings, 0 replies; only message in thread
From: Hayato Kiwata @ 2026-11-25 13:38 UTC (permalink / raw)
To: passt-dev; +Cc: Hayato Kiwata, Stefano Brivio
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 13:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 13:38 [PATCH] pesto: Drop exit_status, use status to select the exit code Hayato Kiwata
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).