[OpenWrt-Devel] [PATCH 7/7] procd: replace exit(-1) with exit(EXIT_FAILURE)

Michael Heimpold mhei at heimpold.de
Tue Jan 1 18:44:59 EST 2019


Signed-off-by: Michael Heimpold <mhei at heimpold.de>
---
 initd/init.c        |  2 +-
 initd/preinit.c     |  6 +++---
 initd/zram.c        |  4 ++--
 plug/coldplug.c     |  3 ++-
 plug/hotplug.c      | 14 +++++++-------
 upgraded/upgraded.c |  2 +-
 6 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/initd/init.c b/initd/init.c
index 0349e6e..8d012f6 100644
--- a/initd/init.c
+++ b/initd/init.c
@@ -91,7 +91,7 @@ main(int argc, char **argv)
 
 		execvp(kmod[0], kmod);
 		ERROR("Failed to start kmodloader: %m\n");
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 	if (pid <= 0) {
 		ERROR("Failed to start kmodloader instance: %m\n");
diff --git a/initd/preinit.c b/initd/preinit.c
index fbb36df..0b0d291 100644
--- a/initd/preinit.c
+++ b/initd/preinit.c
@@ -23,7 +23,7 @@
 #include <libubus.h>
 
 #include <stdio.h>
-
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "init.h"
@@ -135,7 +135,7 @@ preinit(void)
 	if (!plugd_proc.pid) {
 		execvp(plug[0], plug);
 		ERROR("Failed to start plugd: %m\n");
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 	if (plugd_proc.pid <= 0) {
 		ERROR("Failed to start new plugd instance: %m\n");
@@ -157,7 +157,7 @@ preinit(void)
 	if (!preinit_proc.pid) {
 		execvp(init[0], init);
 		ERROR("Failed to start preinit: %m\n");
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 	if (preinit_proc.pid <= 0) {
 		ERROR("Failed to start new preinit instance: %m\n");
diff --git a/initd/zram.c b/initd/zram.c
index b41bfd9..2f92b3f 100644
--- a/initd/zram.c
+++ b/initd/zram.c
@@ -65,7 +65,7 @@ early_insmod(char *module)
 		modprobe[1] = path;
 		execvp(modprobe[0], modprobe);
 		ERROR("Can't exec %s: %m\n", modprobe[0]);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 
 	if (pid <= 0) {
@@ -108,7 +108,7 @@ mount_zram_on_tmp(void)
 	if (!pid) {
 		execvp(mkfs[0], mkfs);
 		ERROR("Can't exec %s: %m\n", mkfs[0]);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	} else if (pid <= 0) {
 		ERROR("Can't exec %s: %m\n", mkfs[0]);
 		return -1;
diff --git a/plug/coldplug.c b/plug/coldplug.c
index c6a89c3..e2d1074 100644
--- a/plug/coldplug.c
+++ b/plug/coldplug.c
@@ -16,6 +16,7 @@
 #include <sys/types.h>
 #include <sys/mount.h>
 
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "../procd.h"
@@ -55,7 +56,7 @@ void procd_coldplug(void)
 	if (!udevtrigger.pid) {
 		execvp(argv[0], argv);
 		ERROR("Failed to start coldplug: %m\n");
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 
 	if (udevtrigger.pid <= 0) {
diff --git a/plug/hotplug.c b/plug/hotplug.c
index 6b5960a..ed61490 100644
--- a/plug/hotplug.c
+++ b/plug/hotplug.c
@@ -206,7 +206,7 @@ static void handle_exec(struct blob_attr *msg, struct blob_attr *data)
 		argv[i] = NULL;
 		execvp(argv[0], &argv[0]);
 	}
-	exit(-1);
+	exit(EXIT_FAILURE);
 }
 
 static void handle_button_start(struct blob_attr *msg, struct blob_attr *data)
@@ -231,7 +231,7 @@ static void handle_firmware(struct blob_attr *msg, struct blob_attr *data)
 
 	if (!file || !dir || !dev) {
 		ERROR("Request for unknown firmware %s/%s\n", dir, file);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 
 	path = alloca(strlen(dir) + strlen(file) + 2);
@@ -256,11 +256,11 @@ send_to_kernel:
 	load = open(loadpath, O_WRONLY);
 	if (!load) {
 		ERROR("Failed to open %s: %m\n", loadpath);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 	if (write(load, "1", 1) == -1) {
 		ERROR("Failed to write to %s: %m\n", loadpath);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 	close(load);
 
@@ -268,7 +268,7 @@ send_to_kernel:
 	fw = open(syspath, O_WRONLY);
 	if (fw < 0) {
 		ERROR("Failed to open %s: %m\n", syspath);
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 
 	len = s.st_size;
@@ -294,7 +294,7 @@ send_to_kernel:
 
 	DEBUG(2, "Done loading %s\n", path);
 
-	exit(-1);
+	exit(EXIT_FAILURE);
 }
 
 static void handle_start_console(struct blob_attr *msg, struct blob_attr *data)
@@ -308,7 +308,7 @@ static void handle_start_console(struct blob_attr *msg, struct blob_attr *data)
 
 	DEBUG(2, "Done starting console for %s\n", dev);
 
-	exit(-1);
+	exit(EXIT_FAILURE);
 }
 
 enum {
diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c
index 0b82f20..db98701 100644
--- a/upgraded/upgraded.c
+++ b/upgraded/upgraded.c
@@ -56,7 +56,7 @@ static void sysupgrade(char *path, char *command)
 		/* Child */
 		execvp(args[0], args);
 		fprintf(stderr, "Failed to exec sysupgrade\n");
-		_exit(-1);
+		_exit(EXIT_FAILURE);
 	}
 
 	uloop_process_add(&upgrade_proc);
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list