* [PATCH v2] ksmbd-tools: Standardize exit codes
@ 2021-11-04 8:34 Guillaume Castagnino
2021-11-05 8:25 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Castagnino @ 2021-11-04 8:34 UTC (permalink / raw)
To: linux-cifs; +Cc: Guillaume Castagnino
In case of success, EXIT_SUCCESS must be returned by the control binary
This standard behaviour is expected for example for the unit file
Standardize failure codes instead of returning directly function error
code
Signed-off-by: Guillaume Castagnino <casta@xwing.info>
---
control/control.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/control/control.c b/control/control.c
index 5b86355..780a48a 100644
--- a/control/control.c
+++ b/control/control.c
@@ -38,12 +38,12 @@ static int ksmbd_control_shutdown(void)
fd = open("/sys/class/ksmbd-control/kill_server", O_WRONLY);
if (fd < 0) {
pr_err("open failed: %d\n", errno);
- return fd;
+ return EXIT_FAILURE;
}
ret = write(fd, "hard", 4);
close(fd);
- return ret;
+ return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
}
static int ksmbd_control_show_version(void)
@@ -54,14 +54,14 @@ static int ksmbd_control_show_version(void)
fd = open("/sys/module/ksmbd/version", O_RDONLY);
if (fd < 0) {
pr_err("open failed: %d\n", errno);
- return fd;
+ return EXIT_FAILURE;
}
ret = read(fd, ver, 255);
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)
@@ -72,7 +72,7 @@ static int ksmbd_control_debug(char *comp)
fd = open("/sys/class/ksmbd-control/debug", O_RDWR);
if (fd < 0) {
pr_err("open failed: %d\n", errno);
- return fd;
+ return EXIT_FAILURE;
}
ret = write(fd, comp, strlen(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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ksmbd-tools: Standardize exit codes
2021-11-04 8:34 [PATCH v2] ksmbd-tools: Standardize exit codes Guillaume Castagnino
@ 2021-11-05 8:25 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2021-11-05 8:25 UTC (permalink / raw)
To: Guillaume Castagnino; +Cc: linux-cifs
2021-11-04 17:34 GMT+09:00, Guillaume Castagnino <casta@xwing.info>:
> In case of success, EXIT_SUCCESS must be returned by the control binary
> This standard behaviour is expected for example for the unit file
> Standardize failure codes instead of returning directly function error
> code
>
> Signed-off-by: Guillaume Castagnino <casta@xwing.info>
Applied, Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-05 8:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 8:34 [PATCH v2] ksmbd-tools: Standardize exit codes Guillaume Castagnino
2021-11-05 8:25 ` Namjae Jeon
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.