From 8dfa06b867baac47eabc6af3549c2c6a276670b7 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 30 Mar 2016 13:29:59 +0200 Subject: lib: bugfixes in flow forgotten return statement forgotten NULL check --- src/lib/flow.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/flow.c b/src/lib/flow.c index 67b8e71b..ab9ad802 100644 --- a/src/lib/flow.c +++ b/src/lib/flow.c @@ -30,6 +30,11 @@ flow_t * flow_create(int32_t port_id) { flow_t * flow = malloc(sizeof *flow); + if (flow == NULL) { + LOG_DBGF("Could not malloc flow."); + return NULL; + } + flow->port_id = port_id; flow->oflags = FLOW_O_DEFAULT; flow->state = FLOW_INIT; @@ -47,7 +52,7 @@ void flow_destroy(flow_t * flow) int flow_set_opts(flow_t * flow, uint16_t opts) { if (flow == NULL) { - LOG_ERR("Non-existing flow."); + LOG_DBGF("Non-existing flow."); return -1; } @@ -57,6 +62,7 @@ int flow_set_opts(flow_t * flow, uint16_t opts) pthread_mutex_unlock(&flow->lock); LOG_WARN("Invalid flow options. Setting default."); opts = FLOW_O_DEFAULT; + return -1; } flow->oflags = opts; @@ -69,7 +75,7 @@ int flow_set_opts(flow_t * flow, uint16_t opts) uint16_t flow_get_opts(const flow_t * flow) { if (flow == NULL) { - LOG_ERR("Non-existing flow."); + LOG_DBGF("Non-existing flow."); return FLOW_O_INVALID; } -- cgit v1.2.3