[systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb

Lennart Poettering lennart at poettering.net
Thu Nov 27 03:31:33 PST 2014


On Thu, 27.11.14 15:19, Peter Hutterer (peter.hutterer at who-t.net) wrote:

> Currently a property in the form of
>   FOO=bar
> is stored as " FOO=bar", i.e. the property name contains a leading space.
> That's quite hard to spot.
> 
> This patch discards all extra whitespaces but the first one which is required
> by libudev's hwdb_add_property.
> ---
>  src/udev/udevadm-hwdb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
> index 3ca755e..dcc6e0f 100644
> --- a/src/udev/udevadm-hwdb.c
> +++ b/src/udev/udevadm-hwdb.c
> @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list,
>          value[0] = '\0';
>          value++;
>  
> +        /* libudev requires properties to start with a space */
> +        while(line[0] != '\0' && isblank(line[1]))
> +            line++;
> +

Please use this instead:

       line += strspn(line, WHITESPACE);

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list