summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 17:51:08 +0100
committerAnthony G. Basile <blueness@gentoo.org>2014-02-21 10:07:51 -0500
commit4e8d48be86ced6c8f8a85cccd63f494d5bcc0fb2 (patch)
tree34aa3cca714a6f174d3f80aef39194ca80b29811
parent63a51878845e21293bf8f808a1e1c8c4bb775332 (diff)
udev: make sure we always return a valid error code in trie_store()
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--src/udev/udevadm-hwdb.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 61662fb4ae..de535de754 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -348,7 +348,7 @@ static int trie_store(struct trie *trie, const char *filename) {
struct trie_f t = {
.trie = trie,
};
- char *filename_tmp;
+ _cleanup_free_ char *filename_tmp = NULL;
int64_t pos;
int64_t root_off;
int64_t size;
@@ -392,8 +392,8 @@ static int trie_store(struct trie *trie, const char *filename) {
err = -errno;
fclose(t.f);
if (err < 0 || rename(filename_tmp, filename) < 0) {
- unlink(filename_tmp);
- goto out;
+ unlink_noerrno(filename_tmp);
+ return err < 0 ? err : -errno;
}
log_debug("=== trie on-disk ===");
@@ -407,9 +407,8 @@ static int trie_store(struct trie *trie, const char *filename) {
t.values_count * sizeof(struct trie_value_entry_f), t.values_count);
log_debug("string store: %8zu bytes", trie->strings->len);
log_debug("strings start: %8"PRIu64, t.strings_off);
-out:
- free(filename_tmp);
- return err;
+
+ return 0;
}
static int insert_data(struct trie *trie, struct udev_list *match_list,