chiark / gitweb /
core: initialize variable
[elogind.git] / src / libudev / libudev-hwdb.c
index a56ad753e45479f673f9c4a01b799362bc306edb..b53b35ce4a754c80e30cf3f01e934632775ddb0f 100644 (file)
@@ -140,9 +140,13 @@ static const struct trie_node_f *node_lookup_f(struct udev_hwdb *hwdb, const str
 }
 
 static int hwdb_add_property(struct udev_hwdb *hwdb, const char *key, const char *value) {
-        /* TODO: add sub-matches (+) against DMI data */
+        /*
+         * Silently ignore all properties which do not start with a
+         * space; future extensions might use additional prefixes.
+         */
         if (key[0] != ' ')
                 return 0;
+
         if (udev_list_entry_add(&hwdb->properties_list, key+1, value) == NULL)
                 return -ENOMEM;
         return 0;
@@ -330,14 +334,14 @@ _public_ struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb) {
  * Drop a reference of a hwdb context. If the refcount reaches zero,
  * all resources of the hwdb context will be released.
  *
- * Returns: the passed hwdb context if it has still an active reference, or #NULL otherwise.
+ * Returns: #NULL
  **/
 _public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
         if (!hwdb)
                 return NULL;
         hwdb->refcount--;
         if (hwdb->refcount > 0)
-                return hwdb;
+                return NULL;
         if (hwdb->map)
                 munmap((void *)hwdb->map, hwdb->st.st_size);
         if (hwdb->f)
@@ -354,7 +358,7 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) {
                 return false;
         if (!hwdb->f)
                 return false;
-        if (fstat(fileno(hwdb->f), &st) < 0)
+        if (stat("/etc/udev/hwdb.bin", &st) < 0)
                 return true;
         if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim))
                 return true;