All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Castagnino <casta@xwing.info>
To: linux-cifs@vger.kernel.org
Cc: Guillaume Castagnino <casta@xwing.info>
Subject: [PATCH] ksmbd-tools: Standardize exit codes
Date: Wed,  3 Nov 2021 16:10:18 +0100	[thread overview]
Message-ID: <20211103151018.172802-1-casta@xwing.info> (raw)

In case of success, EXIT_SUCCESS must be returned by the control binary
This standard behaviour is expected for example for the unit file

Signed-off-by: Guillaume Castagnino <casta@xwing.info>
---
 control/control.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/control/control.c b/control/control.c
index 5b86355..5ff2780 100644
--- a/control/control.c
+++ b/control/control.c
@@ -43,7 +43,7 @@ static int ksmbd_control_shutdown(void)
 
 	ret = write(fd, "hard", 4);
 	close(fd);
-	return ret;
+	return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 static int ksmbd_control_show_version(void)
@@ -61,7 +61,7 @@ static int ksmbd_control_show_version(void)
 	close(fd);
 	if (ret != -1)
 		pr_info("ksmbd version : %s\n", ver);
-	return ret;
+	return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 static int ksmbd_control_debug(char *comp)
@@ -85,7 +85,7 @@ static int ksmbd_control_debug(char *comp)
 	pr_info("%s\n", buf);
 out:
 	close(fd);
-	return ret;
+	return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 int main(int argc, char *argv[])
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
 	while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
 		switch (c) {
 		case 's':
-			ksmbd_control_shutdown();
+			ret = ksmbd_control_shutdown();
 			break;
 		case 'd':
 			ret = ksmbd_control_debug(optarg);
-- 
2.33.1


             reply	other threads:[~2021-11-03 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 15:10 Guillaume Castagnino [this message]
2021-11-03 23:26 ` [PATCH] ksmbd-tools: Standardize exit codes Namjae Jeon
2021-11-04  8:33   ` Guillaume Castagnino

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=20211103151018.172802-1-casta@xwing.info \
    --to=casta@xwing.info \
    --cc=linux-cifs@vger.kernel.org \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.