From 6af30e5b2ed0bd1709d84f870eaee0b5b7396080 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 20 Dec 2010 08:57:17 +0100 Subject: [PATCH] Handle a clang warning that says dstq can be null referenced. In no call of FlowRequeue dstq can be null so not a real issue. Added a BUG_ON just in case, but only in DEBUG mode to prevent the extra overhead. If the code changes we will run it in DEBUG mode and catch the error. --- src/flow-queue.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/flow-queue.c b/src/flow-queue.c index ecd1aaaac2..77357d1992 100644 --- a/src/flow-queue.c +++ b/src/flow-queue.c @@ -108,10 +108,23 @@ Flow *FlowDequeue (FlowQueue *q) { return f; } +/** + * \brief Transfer a flow from one queue to another + * + * \param f the flow to be transfered + * \param srcq the source queue, where the flow will be removed. The param may + * be NULL. + * \param dstq the dest queue where the flow will be placed + * \param need_srclock does the srcq need locking? 1 yes, 0 no + * + */ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock) { - if (srcq != NULL) - { +#ifdef DEBUG + BUG_ON(dstq == NULL); +#endif /* DEBUG */ + + if (srcq != NULL) { if (need_srclock == 1) { SCMutexLock(&srcq->mutex_q); } @@ -131,11 +144,15 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock f->lprev = NULL; /* don't unlock if src and dst are the same */ - if (srcq != dstq && need_srclock == 1) SCMutexUnlock(&srcq->mutex_q); + if (srcq != dstq && need_srclock == 1) { + SCMutexUnlock(&srcq->mutex_q); + } } /* now put it in dst */ - if (srcq != dstq) SCMutexLock(&dstq->mutex_q); + if (srcq != dstq) { + SCMutexLock(&dstq->mutex_q); + } /* add to new queue (append) */ f->lprev = dstq->bot; @@ -155,4 +172,3 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock SCMutexUnlock(&dstq->mutex_q); } -