summaryrefslogtreecommitdiff
path: root/src/hwdb
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-09-18 12:49:51 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-09-19 16:52:59 +0900
commitbf84dc168c23872a3e6b37c3daa5d26950c82bda (patch)
treef47aa2c9ccb023b18ddf113efed3725cddacf23c /src/hwdb
parent124b3686f97a022c7c04e25edb06ef547492c497 (diff)
downloadsystemd-bf84dc168c23872a3e6b37c3daa5d26950c82bda.tar.gz
hwdb: make trie_node_cleanup() can take NULL
Diffstat (limited to 'src/hwdb')
-rw-r--r--src/hwdb/hwdb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c
index ec96923357..a2c1f7da22 100644
--- a/src/hwdb/hwdb.c
+++ b/src/hwdb/hwdb.c
@@ -113,6 +113,9 @@ static struct trie_node *node_lookup(const struct trie_node *node, uint8_t c) {
static void trie_node_cleanup(struct trie_node *node) {
size_t i;
+ if (!node)
+ return;
+
for (i = 0; i < node->children_count; i++)
trie_node_cleanup(node->children[i].child);
free(node->children);
@@ -124,9 +127,7 @@ static void trie_free(struct trie *trie) {
if (!trie)
return;
- if (trie->root)
- trie_node_cleanup(trie->root);
-
+ trie_node_cleanup(trie->root);
strbuf_cleanup(trie->strings);
free(trie);
}