From: Victor Julien Date: Wed, 13 Nov 2019 18:50:48 +0000 (+0100) Subject: threading/queues: simplify error handling X-Git-Tag: suricata-6.0.0-beta1~778 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=272a5f526b7358e215012747178bb2d9120d7a34;p=thirdparty%2Fsuricata.git threading/queues: simplify error handling --- diff --git a/src/tm-queues.c b/src/tm-queues.c index 78d1a6d9e9..6c745bc275 100644 --- a/src/tm-queues.c +++ b/src/tm-queues.c @@ -36,27 +36,24 @@ Tmq *TmqCreateQueue(const char *name) { Tmq *q = SCCalloc(1, sizeof(*q)); if (q == NULL) - goto error; + FatalError(SC_ERR_MEM_ALLOC, "SCCalloc failed"); q->name = SCStrdup(name); if (q->name == NULL) - goto error; + FatalError(SC_ERR_MEM_ALLOC, "SCStrdup failed"); q->id = tmq_id++; q->is_packet_pool = (strcmp(q->name, "packetpool") == 0); - - q->pq = PacketQueueAlloc(); - if (q->pq == NULL) - goto error; + if (!q->is_packet_pool) { + q->pq = PacketQueueAlloc(); + if (q->pq == NULL) + FatalError(SC_ERR_MEM_ALLOC, "PacketQueueAlloc failed"); + } TAILQ_INSERT_HEAD(&tmq_list, q, next); SCLogDebug("created queue \'%s\', %p", name, q); return q; - -error: - SCLogError(SC_ERR_THREAD_QUEUE, "thread queue setup failed for '%s'", name); - return NULL; } Tmq *TmqGetQueueByName(const char *name)