#undef info
#define info(format, arg...) \
do { \
- log_message (LOG_INFO , format , ## arg); \
+ log_message(LOG_INFO , format , ## arg); \
} while (0)
#ifdef DEBUG
#undef dbg
#define dbg(format, arg...) \
do { \
- log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
} while (0)
#endif
#undef dbg_parse
#define dbg_parse(format, arg...) \
do { \
- log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
} while (0)
#endif
-extern void log_message (int level, const char *format, ...)
+extern void log_message(int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
/* each program that uses syslog must declare this variable somewhere */
pos = string;
while (1) {
- pos = strchr(pos, '%');
+ pos = strchr(string, '%');
if (pos != NULL) {
pos[0] = '\0';
tail = pos+1;
case 'b':
if (strlen(udev->bus_id) == 0)
break;
- strnfieldcat(pos, udev->bus_id, maxsize);
+ strnfieldcat(string, udev->bus_id, maxsize);
dbg("substitute bus_id '%s'", udev->bus_id);
break;
case 'k':
if (strlen(udev->kernel_name) == 0)
break;
- strnfieldcat(pos, udev->kernel_name, maxsize);
+ strnfieldcat(string, udev->kernel_name, maxsize);
dbg("substitute kernel name '%s'", udev->kernel_name);
break;
case 'n':
if (strlen(udev->kernel_number) == 0)
break;
- strnfieldcat(pos, udev->kernel_number, maxsize);
+ strnfieldcat(string, udev->kernel_number, maxsize);
dbg("substitute kernel number '%s'", udev->kernel_number);
break;
case 'm':
}
}
if (pos3) {
- strnfieldcat(pos, pos3, maxsize);
+ strnfieldcat(string, pos3, maxsize);
dbg("substitute part of result string '%s'", pos3);
}
} else {
- strnfieldcat(pos, udev->program_result, maxsize);
+ strnfieldcat(string, udev->program_result, maxsize);
dbg("substitute result string '%s'", udev->program_result);
}
break;
dbg("sysfa attribute '%s' not found", attr);
break;
}
- strnfieldcpy(pos, tmpattr->value, maxsize);
+ strnfieldcat(string, tmpattr->value, maxsize);
dbg("substitute sysfs value '%s'", tmpattr->value);
} else {
dbg("missing attribute");
}
break;
case '%':
- strnfieldcat(pos, "%", maxsize);
+ strnfieldcat(string, "%", maxsize);
break;
default:
dbg("unknown substitution type '%%%c'", c);
break;
}
- strnfieldcat(pos, tail, maxsize);
+ strnfieldcat(string, tail, maxsize);
}
}
#ifdef LOG
unsigned char logname[42];
-void log_message (int level, const char *format, ...)
+void log_message(int level, const char *format, ...)
{
va_list args;
"",
};
-static int udev_hotplug(int argc, char **argv)
+static int udev_hotplug(void)
{
char *action;
char *devpath;
}
/* skip blacklisted subsystems */
- subsystem = get_subsystem(argv[1]);
+ subsystem = get_subsystem(main_argv[1]);
if (!subsystem) {
dbg("no subsystem?");
goto exit;
/* connect to the system message bus */
sysbus_connect();
- /* initialize our configuration */
- udev_init_config();
-
/* initialize udev database */
retval = udevdb_init(UDEVDB_DEFAULT);
if (retval != 0) {
main_envp = envp;
init_logging("udev");
+
+ /* initialize our configuration */
+ udev_init_config();
+
dbg("version %s", UDEV_VERSION);
- return udev_hotplug(argc, argv);
+ return udev_hotplug();
}
char *action;
action = getenv("ACTION");
- if (strlen(action) > ACTION_SIZE)
+ if (action != NULL && strlen(action) > ACTION_SIZE)
action[ACTION_SIZE-1] = '\0';
return action;
char *devpath;
devpath = getenv("DEVPATH");
- if (strlen(devpath) > DEVPATH_SIZE)
+ if (devpath != NULL && strlen(devpath) > DEVPATH_SIZE)
devpath[DEVPATH_SIZE-1] = '\0';
return devpath;
static inline char *get_subsystem(char *subsystem)
{
- if (strlen(subsystem) > SUBSYSTEM_SIZE)
+ if (subsystem != NULL && strlen(subsystem) > SUBSYSTEM_SIZE)
subsystem[SUBSYSTEM_SIZE-1] = '\0';
return subsystem;