hwdb: remove path comparison which broke overriding of properties

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 3a04b789c6
(not in spirit, but in the implementation).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-11-29 14:46:40 -05:00
parent 0f2e01a503
commit 389be927b4

View 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;