[Oisf-devel] Source code technical question

Duarte Silva duarte.silva at serializing.me
Wed Jul 24 13:21:47 UTC 2013


Hi all,

I was dwelling into Suricata source code and came across this:

#define DEBUG_ASSERT_FLOW_LOCKED(f) do {            \
    if ((f) != NULL) {                              \
        int r = SCMutexTrylock(&(f)->m);            \
        if (r == 0) {                               \
            BUG_ON(1);                              \
        }                                           \
    }                                               \
} while(0)

Just wondering, whats the advantage of having this inside a do/while? Is it 
because the compiler will optimize it out if not in a debug build?

Best regards,
Duarte


More information about the Oisf-devel mailing list