[systemd-devel] [PATCH 1/2]add parameters checking for 'udevadm settle'

Yang Zhiyong yangzy.fnst at cn.fujitsu.com
Wed Oct 23 09:09:36 CEST 2013


This patch adds parameters checking for 'udevadm settle'
Signed-off-by: Yang Zhiyong <yangzy.fnst at cn.fujitsu.com>
---
 src/udev/udevadm-settle.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
 mode change 100644 => 100755 src/udev/udevadm-settle.c

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
old mode 100644
new mode 100755
index c4fc4ee..cacc7e3
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -62,8 +62,13 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
                 int seconds;
 
                 option = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL);
-                if (option == -1)
+                if (option == -1) {
+                        if (optind < argc) {
+                                fprintf(stderr, "unknown option\n");
+                                exit(EXIT_FAILURE);
+                        }
                         break;
+                }
 
                 switch (option) {
                 case 's':
@@ -74,10 +79,14 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
                         break;
                 case 't':
                         seconds = atoi(optarg);
-                        if (seconds >= 0)
+                        if (seconds > 0)
                                 timeout = seconds;
-                        else
+                        else if (seconds == 0 && !strcmp(optarg,"0"))
+                                timeout = seconds;
+                        else {
                                 fprintf(stderr, "invalid timeout value\n");
+                                exit(EXIT_FAILURE);
+                        }
                         break;
                 case 'q':
                         quiet = 1;
-- 
1.7.1




More information about the systemd-devel mailing list