summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-06-28 23:42:52 +0200
committerTom Gundersen <teg@jklm.no>2015-06-29 19:51:04 +0200
commitbbf35206735f97cf3fcda8d26982b35b0cad20a9 (patch)
tree22c7f66a5ea8f058e56929085c63216399a2a8e5 /src/udev/udev-rules.c
parent1cf34d7118e93f0734a52d0eb09f238cf9962b85 (diff)
udev: event - simplify udev_event_spawn() logic
Push the extraction of the envp + argv as close as possible to their use, to avoid code duplication. As a sideeffect fix logging when delaing execution.
Diffstat (limited to 'src/udev/udev-rules.c')
-rw-r--r--src/udev/udev-rules.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 8ebc061eb1..c3e2e211e3 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -634,14 +634,11 @@ static int import_program_into_properties(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
const char *program) {
- struct udev_device *dev = event->dev;
- char **envp;
char result[UTIL_LINE_SIZE];
char *line;
int err;
- envp = udev_device_get_properties_envp(dev);
- err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result));
+ err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, result, sizeof(result));
if (err < 0)
return err;
@@ -654,7 +651,7 @@ static int import_program_into_properties(struct udev_event *event,
pos[0] = '\0';
pos = &pos[1];
}
- import_property_from_string(dev, line);
+ import_property_from_string(event->dev, line);
line = pos;
}
return 0;
@@ -2119,19 +2116,17 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
}
case TK_M_PROGRAM: {
char program[UTIL_PATH_SIZE];
- char **envp;
char result[UTIL_LINE_SIZE];
free(event->program_result);
event->program_result = NULL;
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), program, sizeof(program));
- envp = udev_device_get_properties_envp(event->dev);
log_debug("PROGRAM '%s' %s:%u",
program,
rules_str(rules, rule->rule.filename_off),
rule->rule.filename_line);
- if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result)) < 0) {
+ if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, result, sizeof(result)) < 0) {
if (cur->key.op != OP_NOMATCH)
goto nomatch;
} else {