]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwdb: remove path comparison which broke overriding of properties
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Nov 2016 19:46:40 +0000 (14:46 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 30 Nov 2016 20:48:11 +0000 (15:48 -0500)
Partial fix for #4750.

We would compare strings like "/usr/lib/udev/hwdb.d/something.hwdb" and
"/etc/udev/hwdb.db/something.hwdb" and conclude that the first has higher
priority. Since we process files in order (higher priority later), no
comparison is necessary when loading.

This partially undoes 3a04b789c6f17dff2000a3cdbeaaf86baa604524
(not in spirit, but in the implementation).

src/hwdb/hwdb.c

index 1d16d9f8aa04b9f3d1162e33311fa61e0c01cea3..af31578e11fd1934e68af8373dad41fed6ae9a25 100644 (file)
@@ -163,7 +163,6 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
                                const char *filename, size_t line_number) {
         ssize_t k, v, fn;
         struct trie_value_entry *val;
-        int r;
 
         k = strbuf_add_string(trie->strings, key, strlen(key));
         if (k < 0)
@@ -183,17 +182,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
 
                 val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie);
                 if (val) {
-                        /*
-                         * At this point we have 2 identical properties on the same match-string. We
-                         * strictly order them by filename+line-number, since we know the dynamic
-                         * runtime lookup does the same for multiple matching nodes.
+                        /* At this point we have 2 identical properties on the same match-string.
+                         * Since we process files in order, we just replace the previous value.
                          */
-                        r = strcmp(filename, trie->strings->buf + val->filename_off);
-                        if (r < 0 ||
-                            (r == 0 && line_number < val->line_number))
-                                return 0;
-
-                        /* replace existing earlier key with new value */
                         val->value_off = v;
                         val->filename_off = fn;
                         val->line_number = line_number;