summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-11-28 21:46:34 +0100
committerAnthony G. Basile <blueness@gentoo.org>2014-12-01 19:43:58 -0500
commitb3a572ddf5623be53c2690a1412b61a95315a724 (patch)
treeec5c0b11e41f2a3cf99383fe5df383420a483682 /src/udev
parent5cb98078479d93e25099c1cb73fa9c46aa9ccf29 (diff)
udev: rules - print the first invalid character
The current code would print the character following the first invalid character. Given an udev rules-file without a trailing newline we would otherwise print garbage: invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('m') This is now changed to print invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('') (still not very good as printing \0 just gives the empty string) Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-rules.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 107c20bb51..eb8c28a407 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1073,13 +1073,13 @@ static int add_rule(struct udev_rules *rules, char *line,
/* If we aren't at the end of the line, this is a parsing error.
* Make a best effort to describe where the problem is. */
if (*linepos != '\n') {
- char buf[2] = {linepos[1]};
+ char buf[2] = {*linepos};
_cleanup_free_ char *tmp;
tmp = cescape(buf);
log_error("invalid key/value pair in file %s on line %u, starting at character %tu ('%s')",
filename, lineno, linepos - line + 1, tmp);
- if (linepos[1] == '#')
+ if (*linepos == '#')
log_error("hint: comments can only start at beginning of line");
}
break;