diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-27 19:09:22 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-03-02 12:39:07 +0100 |
commit | 62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch) | |
tree | 138ea4e336b01254a6766e547fdc10c3728255ef /src/hwdb | |
parent | 3209c8e6502c095bb7a88a3e915f06dd56228ed4 (diff) | |
download | systemd-62d74c78b59f95a76778d9fa8dbe3b098afa2aad.tar.gz |
coccinelle: add reallocarray() coccinelle script
Let's systematically make use of reallocarray() whereever we invoke
realloc() with a product of two values.
Diffstat (limited to 'src/hwdb')
-rw-r--r-- | src/hwdb/hwdb.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c index 4540260f9b..f27f60e977 100644 --- a/src/hwdb/hwdb.c +++ b/src/hwdb/hwdb.c @@ -103,7 +103,7 @@ static int node_add_child(struct trie *trie, struct trie_node *node, struct trie struct trie_child_entry *child; /* extend array, add new entry, sort for bisection */ - child = realloc(node->children, (node->children_count + 1) * sizeof(struct trie_child_entry)); + child = reallocarray(node->children, node->children_count + 1, sizeof(struct trie_child_entry)); if (!child) return -ENOMEM; @@ -197,7 +197,7 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, } /* extend array, add new entry, sort for bisection */ - val = realloc(node->values, (node->values_count + 1) * sizeof(struct trie_value_entry)); + val = reallocarray(node->values, node->values_count + 1, sizeof(struct trie_value_entry)); if (!val) return -ENOMEM; trie->values_count++; |