From 7d0fcf6392be6a738d0ba7450b62f8c48062279a Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 8 May 2016 16:14:35 +0200 Subject: lib/irmd/ipcpd/tools: fixes comments on eb9f443 --- src/lib/bitmap.c | 9 ++++++--- src/lib/dev.c | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index 0e3c968f..e84145b2 100644 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -112,7 +112,7 @@ struct bmp * bmp_create(size_t bits, ssize_t offset) return NULL; tmp->bitmap = malloc(BITS_TO_LONGS(bits) * sizeof(unsigned long)); - if (!tmp->bitmap) { + if (tmp->bitmap == NULL) { free(tmp); return NULL; } @@ -142,6 +142,9 @@ int bmp_destroy(struct bmp * b) static ssize_t bad_id(struct bmp * b) { + if (b == NULL) + return -1; + return b->offset - 1; } @@ -177,7 +180,7 @@ static bool is_id_valid(struct bmp * b, bool bmp_is_id_valid(struct bmp * b, ssize_t id) { - if (!b) + if (b == NULL) return false; return is_id_valid(b, id); @@ -188,7 +191,7 @@ int bmp_release(struct bmp * b, { ssize_t rid; - if (!b) + if (b == NULL) return -1; if (!is_id_valid(b, id)) diff --git a/src/lib/dev.c b/src/lib/dev.c index 40bf2dc3..c99e8cdb 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -249,12 +249,26 @@ int flow_accept(int fd, return -1; } + *ap_name = strdup(recv_msg->ap_name); + if (*ap_name == NULL) { + bmp_release(_ap_instance->fds, cfd); + irm_msg__free_unpacked(recv_msg, NULL); + return -1; + } + + if (ae_name != NULL) { + *ae_name = strdup(recv_msg->ae_name); + if (*ae_name == NULL) { + bmp_release(_ap_instance->fds, cfd); + irm_msg__free_unpacked(recv_msg, NULL); + return -1; + } + } + _ap_instance->flows[cfd].port_id = recv_msg->port_id; _ap_instance->flows[cfd].oflags = FLOW_O_DEFAULT; - *ap_name = strdup(recv_msg->ap_name); - if (ae_name != NULL) - *ae_name = strdup(recv_msg->ae_name); + irm_msg__free_unpacked(recv_msg, NULL); -- cgit v1.2.3