chiark / gitweb /
build-sys: update catalog on installation
[elogind.git] / src / libudev / libudev-hwdb.c
index 92c58b61a2594a9592620ca496e655e4fd6057a5..6779e45b4e5302e675c29b711be17b7fbb33769c 100644 (file)
@@ -1,7 +1,7 @@
 /***
   This file is part of systemd.
 
-  Copyright 2012 Kay Sievers <kay.sievers@vrfy.org>
+  Copyright 2012 Kay Sievers <kay@vrfy.org>
   Copyright 2008 Alan Jenkins <alan.christopher.jenkins@googlemail.com>
 
   systemd is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
  * SECTION:libudev-hwdb
  * @short_description: retrieve properties from the hardware database
  *
- * Libuded hardware database interface.
+ * Libudev hardware database interface.
  */
 
 /**
@@ -338,10 +338,10 @@ _public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
         hwdb->refcount--;
         if (hwdb->refcount > 0)
                 return hwdb;
-        if (hwdb->f)
-                fclose(hwdb->f);
         if (hwdb->map)
                 munmap((void *)hwdb->map, hwdb->st.st_size);
+        if (hwdb->f)
+                fclose(hwdb->f);
         udev_list_cleanup(&hwdb->properties_list);
         free(hwdb);
         return NULL;
@@ -356,7 +356,7 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) {
                 return false;
         if (fstat(fileno(hwdb->f), &st) < 0)
                 return true;
-        if (ts_usec(&hwdb->st.st_mtim) != ts_usec(&st.st_mtim))
+        if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim))
                 return true;
         return false;
 }
@@ -377,11 +377,12 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) {
 _public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags) {
         int err;
 
-        if (!hwdb->f) {
+        if (!hwdb || !hwdb->f) {
                 errno = EINVAL;
                 return NULL;
         }
 
+        udev_list_cleanup(&hwdb->properties_list);
         err = trie_search_f(hwdb, modalias);
         if (err < 0) {
                 errno = -err;