From: Kay Sievers Date: Sat, 14 Jul 2007 18:43:43 +0000 (+0200) Subject: use global udev_log variable instead of parameter in run_program X-Git-Tag: 174~1890 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb819f5554530dd136d50aa40438e9dbeeceac01;p=systemd use global udev_log variable instead of parameter in run_program --- diff --git a/test-udev.c b/test-udev.c index ba360159..f114609e 100644 --- a/test-udev.c +++ b/test-udev.c @@ -166,7 +166,7 @@ int main(int argc, char *argv[], char *envp[]) strlcpy(program, name_loop->name, sizeof(program)); udev_rules_apply_format(udev, program, sizeof(program)); - run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO)); + run_program(program, udev->dev->subsystem, NULL, 0, NULL); } } } diff --git a/udev.h b/udev.h index baf58a81..c056835f 100644 --- a/udev.h +++ b/udev.h @@ -169,6 +169,6 @@ extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur); /* udev_utils_run.c */ extern int pass_env_to_socket(const char *name, const char *devpath, const char *action); extern int run_program(const char *command, const char *subsystem, - char *result, size_t ressize, size_t *reslen, int log); + char *result, size_t ressize, size_t *reslen); #endif diff --git a/udev_rules.c b/udev_rules.c index b2b4809d..9483c2b8 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -190,7 +190,7 @@ static int import_program_into_env(struct udevice *udev, const char *program) char result[2048]; size_t reslen; - if (run_program(program, udev->dev->subsystem, result, sizeof(result), &reslen, (udev_log_priority >= LOG_INFO)) != 0) + if (run_program(program, udev->dev->subsystem, result, sizeof(result), &reslen) != 0) return -1; return import_keys_into_env(udev, result, reslen); } @@ -837,8 +837,7 @@ try_parent: strlcpy(program, key_val(rule, &rule->program), sizeof(program)); udev_rules_apply_format(udev, program, sizeof(program)); - if (run_program(program, udev->dev->subsystem, result, sizeof(result), - NULL, (udev_log_priority >= LOG_INFO)) != 0) { + if (run_program(program, udev->dev->subsystem, result, sizeof(result), NULL) != 0) { dbg("PROGRAM is false"); udev->program_result[0] = '\0'; if (rule->program.operation != KEY_OP_NOMATCH) diff --git a/udev_utils_run.c b/udev_utils_run.c index 1a92cddd..69b54f47 100644 --- a/udev_utils_run.c +++ b/udev_utils_run.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -69,9 +70,8 @@ int pass_env_to_socket(const char *sockname, const char *devpath, const char *ac } int run_program(const char *command, const char *subsystem, - char *result, size_t ressize, size_t *reslen, int log) + char *result, size_t ressize, size_t *reslen) { - int retval = 0; int status; int outpipe[2] = {-1, -1}; int errpipe[2] = {-1, -1}; @@ -81,6 +81,7 @@ int run_program(const char *command, const char *subsystem, char *argv[(sizeof(arg) / 2) + 1]; int devnull; int i; + int retval = 0; /* build argv from comand */ strlcpy(arg, command, sizeof(arg)); @@ -109,13 +110,13 @@ int run_program(const char *command, const char *subsystem, info("'%s'", command); /* prepare pipes from child to parent */ - if (result || log) { + if (result != NULL || udev_log_priority >= LOG_INFO) { if (pipe(outpipe) != 0) { err("pipe failed: %s", strerror(errno)); return -1; } } - if (log) { + if (udev_log_priority >= LOG_INFO) { if (pipe(errpipe) != 0) { err("pipe failed: %s", strerror(errno)); return -1; diff --git a/udevd.c b/udevd.c index afefb914..5ed8e38c 100644 --- a/udevd.c +++ b/udevd.c @@ -147,8 +147,7 @@ static int udev_event_process(struct udevd_uevent_msg *msg) strlcpy(program, name_loop->name, sizeof(program)); udev_rules_apply_format(udev, program, sizeof(program)); - if (run_program(program, udev->dev->subsystem, NULL, 0, NULL, - (udev_log_priority >= LOG_INFO)) != 0) + if (run_program(program, udev->dev->subsystem, NULL, 0, NULL) != 0) if (!name_loop->ignore_error) retval = -1; } diff --git a/udevstart.c b/udevstart.c index 6af5860e..1e67a061 100644 --- a/udevstart.c +++ b/udevstart.c @@ -160,7 +160,7 @@ static int add_device(const char *devpath) strlcpy(program, name_loop->name, sizeof(program)); udev_rules_apply_format(udev, program, sizeof(program)); - run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO)); + run_program(program, udev->dev->subsystem, NULL, 0, NULL); } } }