chiark / gitweb /
[PATCH] udev - trivial style cleanup
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Tue, 27 Jan 2004 08:40:12 +0000 (00:40 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:19 +0000 (21:13 -0700)
Trivial style cleanup, to be consistent.

And add chdir("/") to the daemon so one can umout its filesystem,
while we are running :)

namedev.c
udevinfo.c
udevsend.c

index 6b1aa29..de7f7c1 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -332,12 +332,8 @@ static int execute_program(char *path, char *value, int len)
                return -1;
        }
        pid = fork();
                return -1;
        }
        pid = fork();
-       if (pid == -1) {
-               dbg("fork failed");
-               return -1;
-       }
-
-       if (pid == 0) {
+       switch(pid) {
+       case 0:
                /* child */
                close(STDOUT_FILENO);
                dup(fds[1]);    /* dup write side of pipe to STDOUT */
                /* child */
                close(STDOUT_FILENO);
                dup(fds[1]);    /* dup write side of pipe to STDOUT */
@@ -353,16 +349,16 @@ static int execute_program(char *path, char *value, int len)
                                dbg("too many args - %d", i);
                                args[i] = NULL;
                        }
                                dbg("too many args - %d", i);
                                args[i] = NULL;
                        }
-                       retval = execve(args[0], args, main_envp);
+                       retval = execv(args[0], args);
                } else {
                } else {
-                       retval = execve(path, main_argv, main_envp);
-               }
-               if (retval != 0) {
-                       dbg("child execve failed");
-                       exit(1);
+                       retval = execv(path, main_argv);
                }
                }
-               return -1; /* avoid compiler warning */
-       } else {
+               dbg("child execve failed");
+               exit(1);
+       case -1:
+               dbg("fork failed");
+               return -1;
+       default:
                /* parent reads from fds[0] */
                close(fds[1]);
                retval = 0;
                /* parent reads from fds[0] */
                close(fds[1]);
                retval = 0;
index aa9d20a..4d28755 100644 (file)
@@ -397,7 +397,7 @@ help:
               "  -n NAME  node name used for query\n"
               "\n"
               "  -r       print udev root\n"
               "  -n NAME  node name used for query\n"
               "\n"
               "  -r       print udev root\n"
-              "  -a       print all attributes along the chain of the device\n"
+              "  -a       print all SYSFS_attributes along the device chain\n"
               "  -d       dump whole database\n"
               "  -V       print udev version\n"
               "  -h       print this help text\n"
               "  -d       dump whole database\n"
               "  -V       print udev version\n"
               "  -h       print this help text\n"
index 3f3bbac..0a305e5 100644 (file)
@@ -87,6 +87,7 @@ static int start_daemon(void)
                case 0:
                        /* daemon */
                        setsid();
                case 0:
                        /* daemon */
                        setsid();
+                       chdir("/");
                        execl(UDEVD_EXEC, "udevd", NULL);
                        dbg("exec of daemon failed");
                        exit(1);
                        execl(UDEVD_EXEC, "udevd", NULL);
                        dbg("exec of daemon failed");
                        exit(1);