summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-27 19:09:22 +0100
committerLennart Poettering <lennart@poettering.net>2018-03-02 12:39:07 +0100
commit62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch)
tree138ea4e336b01254a6766e547fdc10c3728255ef /src/udev/udev-rules.c
parent3209c8e6502c095bb7a88a3e915f06dd56228ed4 (diff)
downloadsystemd-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/udev/udev-rules.c')
-rw-r--r--src/udev/udev-rules.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index f4708bb066..3b0ddb5118 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -465,7 +465,7 @@ static int add_token(struct udev_rules *rules, struct token *token) {
if (add < 8)
add = 8;
- tokens = realloc(rules->tokens, (rules->token_max + add ) * sizeof(struct token));
+ tokens = reallocarray(rules->tokens, rules->token_max + add, sizeof(struct token));
if (tokens == NULL)
return -1;
rules->tokens = tokens;
@@ -511,7 +511,7 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) {
if (add < 1)
add = 8;
- uids = realloc(rules->uids, (rules->uids_max + add ) * sizeof(struct uid_gid));
+ uids = reallocarray(rules->uids, rules->uids_max + add, sizeof(struct uid_gid));
if (uids == NULL)
return uid;
rules->uids = uids;
@@ -554,7 +554,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) {
if (add < 1)
add = 8;
- gids = realloc(rules->gids, (rules->gids_max + add ) * sizeof(struct uid_gid));
+ gids = reallocarray(rules->gids, rules->gids_max + add, sizeof(struct uid_gid));
if (gids == NULL)
return gid;
rules->gids = gids;