[PATCH 2/3] mdev: use option parser helper

Jan Klötzke jan at kloetzke.net
Fri May 3 20:35:51 UTC 2019


Signed-off-by: Jan Klötzke <jan at kloetzke.net>
---
 util-linux/mdev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 8205a260a..9e2f527d7 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -249,6 +249,10 @@
 #endif
 
 
+enum {
+	MDEV_OPT_SCAN       = 1 << 0,
+};
+
 static const char keywords[] ALIGN1 = "add\0remove\0"; // "change\0"
 enum { OP_add, OP_remove };
 
@@ -1130,6 +1134,7 @@ static void initial_scan(char *temp)
 int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int mdev_main(int argc UNUSED_PARAM, char **argv)
 {
+	int opt;
 	RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
 
 	INIT_G();
@@ -1147,7 +1152,9 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 
 	xchdir("/dev");
 
-	if (argv[1] && strcmp(argv[1], "-s") == 0) {
+	opt = getopt32(argv, "s");
+
+	if (opt & MDEV_OPT_SCAN) {
 		/*
 		 * Scan: mdev -s
 		 */
-- 
2.20.1



More information about the busybox mailing list