summaryrefslogtreecommitdiff
path: root/src/udev/udevd.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-11-05 12:56:49 +0100
committerAnthony G. Basile <blueness@gentoo.org>2014-11-07 08:29:22 -0500
commit0f89a3c56311da315e1575eff3eef6efe6eb2039 (patch)
treec53967a4657493aebf10bdfab6817a1080ccaf99 /src/udev/udevd.c
parent7be58d7b4810d0ae0a5bc95be0a427ff91179f73 (diff)
udev: avoid magic constants in kernel-cmdline parsers
Lets recognize the fact that startswith() returns a pointer to the tail on success. Use it instead of hard-coding string-lengths as magic constants. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r--src/udev/udevd.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 304b0fa4c7..2b70165d70 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -994,7 +994,7 @@ static void kernel_cmdline_options(struct udev *udev) {
return;
FOREACH_WORD_QUOTED(word, l, line, state) {
- char *s, *opt;
+ char *s, *opt, *value;
s = strndup(word, l);
if (!s)
@@ -1006,24 +1006,24 @@ static void kernel_cmdline_options(struct udev *udev) {
else
opt = s;
- if (startswith(opt, "udev.log-priority=")) {
+ if ((value = startswith(opt, "udev.log-priority="))) {
int prio;
- prio = util_log_priority(opt + 18);
+ prio = util_log_priority(value);
log_set_max_level(prio);
udev_set_log_priority(udev, prio);
- } else if (startswith(opt, "udev.children-max=")) {
- r = safe_atoi(opt + 18, &arg_children_max);
+ } else if ((value = startswith(opt, "udev.children-max="))) {
+ r = safe_atoi(value, &arg_children_max);
if (r < 0)
- log_warning("Invalid udev.children-max ignored: %s", opt + 18);
- } else if (startswith(opt, "udev.exec-delay=")) {
- r = safe_atoi(opt + 16, &arg_exec_delay);
+ log_warning("Invalid udev.children-max ignored: %s", value);
+ } else if ((value = startswith(opt, "udev.exec-delay="))) {
+ r = safe_atoi(value, &arg_exec_delay);
if (r < 0)
- log_warning("Invalid udev.exec-delay ignored: %s", opt + 16);
- } else if (startswith(opt, "udev.event-timeout=")) {
- r = safe_atou64(opt + 19, &arg_event_timeout_usec);
+ log_warning("Invalid udev.exec-delay ignored: %s", value);
+ } else if ((value = startswith(opt, "udev.event-timeout="))) {
+ r = safe_atou64(value, &arg_event_timeout_usec);
if (r < 0) {
- log_warning("Invalid udev.event-timeout ignored: %s", opt + 19);
+ log_warning("Invalid udev.event-timeout ignored: %s", value);
break;
}
arg_event_timeout_usec *= USEC_PER_SEC;