chiark / gitweb /
[PATCH] overall trivial trivial cleanup
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Thu, 4 Mar 2004 08:57:29 +0000 (00:57 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:35:08 +0000 (21:35 -0700)
Here I try to make the style a bit more consistant in the different
files, so that new patches just copy the 'right' one :)

Some "magic" numbers are replaced and udevtest.c is catched up with udev.

logging.h
namedev_parse.c
udev.c
udevd.c
udevinfo.c
udevsend.c
udevstart.c
udevtest.c

index 1c27917f61e4ed89ecc6e8b6b3a28f615c51d853..40c342c3ab0c04c7b2690c1e34548f06c49ee0ee 100644 (file)
--- a/logging.h
+++ b/logging.h
@@ -34,6 +34,8 @@
 #include <unistd.h>
 #include <syslog.h>
 
+#define LOGNAME_SIZE                   42
+
 #undef info
 #define info(format, arg...)                                                           \
        do {                                                                            \
@@ -61,12 +63,12 @@ extern void log_message(int level, const char *format, ...)
        __attribute__ ((format (printf, 2, 3)));
 
 /* each program that uses syslog must declare this variable somewhere */
-extern unsigned char logname[42];
+extern unsigned char logname[LOGNAME_SIZE];
 
 #undef init_logging
 static inline void init_logging(char *program_name)
 {
-       snprintf(logname, 42,"%s[%d]", program_name, getpid());
+       snprintf(logname, LOGNAME_SIZE,"%s[%d]", program_name, getpid());
        openlog(logname, 0, LOG_DAEMON);
 }
 
index 19acd96ef056cb6b7ecf9b9d36feefbdbfeb52e9..defb698b26ed5962eeeb4590fd7e1c892f527a21 100644 (file)
@@ -58,7 +58,6 @@ static int add_config_dev(struct config_device *new_dev)
 
 void dump_config_dev(struct config_device *dev)
 {
-       /*FIXME dump all sysfs's */
        dbg_parse("name='%s', symlink='%s', bus='%s', place='%s', id='%s', "
                  "sysfs_file[0]='%s', sysfs_value[0]='%s', "
                  "kernel='%s', program='%s', result='%s'",
diff --git a/udev.c b/udev.c
index 227145982ef54da68d913c3a69d332096cfd1367..9b4d91f75cea26373c9aebc7688b0d992d0c3089 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -40,7 +40,7 @@ char **main_argv;
 char **main_envp;
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message(int level, const char *format, ...)
 {
        va_list args;
@@ -74,7 +74,7 @@ static char *subsystem_blacklist[] = {
        "usb_host",
        "pci_bus",
        "pcmcia_socket",
-       "",
+       ""
 };
 
 static int udev_hotplug(void)
@@ -164,7 +164,7 @@ exit:
        return -retval;
 }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char *argv[], char *envp[])
 {
        main_argv = argv;
        main_envp = envp;
diff --git a/udevd.c b/udevd.c
index 2b3dc55788f3e2915c7edf6644e7810b7c062dac..efcb65bb53f3d78da04a723d213f90e0e3332fd9 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -52,7 +52,7 @@ static void exec_queue_manager(void);
 static void msg_queue_manager(void);
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message (int level, const char *format, ...)
 {
        va_list args;
index b15f174e4032706d5c36fee31cadb8bc0fb0de50..3361837a37a98200abde68964df9312079fff6b0 100644 (file)
@@ -41,7 +41,7 @@ char **main_argv;
 int main_argc;
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message (int level, const char *format, ...)
 {
        va_list args;
index 4b6ef5c2f3b7f8929678d85ecd6524cf07113765..11234808d9dbe5729d00fca8f9446195a127ccc5 100644 (file)
@@ -41,7 +41,7 @@
 #include "logging.h"
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message (int level, const char *format, ...)
 {
        va_list args;
index 5c977b5ce65ab0ee92574391d188066814d1329a..21fd93df742b12776664bb10a4ebae1f5c23c11c 100644 (file)
@@ -34,7 +34,7 @@
 
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message(int level, const char *format, ...)
 {
        va_list args;
@@ -187,7 +187,7 @@ static int udev_scan(void)
 }
 
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char *argv[], char *envp[])
 {
        init_logging("udevstart");
 
index 4bc094fd908f8c2f3dd21ea10f287f6de300f6a8..e67d45257786cd2a0cab019e904d5c87bd5e9ac0 100644 (file)
@@ -38,15 +38,11 @@ char **main_argv;
 char **main_envp;
 
 #ifdef LOG
-unsigned char logname[42];
+unsigned char logname[LOGNAME_SIZE];
 void log_message (int level, const char *format, ...)
 {
-       va_list args;
+       va_list args;
 
-//     if (!udev_log)
-//             return;
-
-       /* FIXME use level... */
        va_start(args, format);
        vprintf(format, args);
        va_end(args);
@@ -55,35 +51,24 @@ void log_message (int level, const char *format, ...)
 }
 #endif
 
-static void sig_handler(int signum)
-{
-       switch (signum) {
-               case SIGINT:
-               case SIGTERM:
-                       exit(20 + signum);
-               default:
-                       dbg("unhandled signal");
-       }
-}
-
 static char *subsystem_blacklist[] = {
        "net",
        "scsi_host",
        "scsi_device",
        "usb_host",
        "pci_bus",
-       "",
+       "pcmcia_socket",
+       ""
 };
 
-static int udev_hotplug(int argc, char **argv)
+static int udev_hotplug(void)
 {
        char *devpath;
        char *subsystem;
        int retval = -EINVAL;
        int i;
-       struct sigaction act;
 
-       devpath = argv[1];
+       devpath = main_argv[1];
        if (!devpath) {
                dbg("no devpath?");
                goto exit;
@@ -98,7 +83,7 @@ static int udev_hotplug(int argc, char **argv)
        }
 
        /* skip blacklisted subsystems */
-       subsystem = argv[1];
+       subsystem = main_argv[1];
        i = 0;
        while (subsystem_blacklist[i][0] != '\0') {
                if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
@@ -111,16 +96,10 @@ static int udev_hotplug(int argc, char **argv)
        /* initialize our configuration */
        udev_init_config();
 
-       /* set up a default signal handler for now */
-       act.sa_handler = sig_handler;
-       sigemptyset (&act.sa_mask);
-       act.sa_flags = SA_RESTART;
-       sigaction(SIGINT, &act, NULL);
-       sigaction(SIGTERM, &act, NULL);
-
        /* initialize the naming deamon */
        namedev_init();
 
+       /* simulate node creation with fake flag */
        retval = udev_add_device(devpath, subsystem, 1);
 
 exit:
@@ -130,14 +109,14 @@ exit:
        return -retval;
 }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char *argv[], char *envp[])
 {
        main_argv = argv;
        main_envp = envp;
 
        dbg("version %s", UDEV_VERSION);
 
-       return udev_hotplug(argc, argv);
+       return udev_hotplug();
 }