[Oisf-devel] Source code technical question
Duarte Silva
duarte.silva at serializing.me
Thu Jul 25 09:32:25 UTC 2013
Hi all,
in "util-host-os-info.c", functions "SCHInfoValidateIPV4Address"and
"SCHInfoValidateIPV6Address" are exaclty the same as "util-radix-tree.c"
functions "SCRadixValidateIPV4Address" and "SCRadixValidateIPV6Address".
With a small exception in "SCHInfoValidateIPV4Address", it doesn't exit if the
memory allocation fails.
Would it be a good idea to merge this functions?
Best regards,
Duarte
On Wednesday 24 July 2013 15:10:46 Duarte Silva wrote:
> On Wednesday 24 July 2013 15:47:19 Victor Julien wrote:
> > On 07/24/2013 03:21 PM, Duarte Silva wrote:
> > > 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?
> >
> > Answers can be found on stackoverflow:
> >
> > http://stackoverflow.com/questions/923822/whats-the-use-of-do-while0-when-> > we -define-a-macro
> > http://stackoverflow.com/questions/154136/do-while-and-if-else-statements-> > i
> > n-c-c-macros
> > http://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for
>
> Thanks Victor, I should have googled it :D it never crossed my mind it had
> anything to do with semi-colons and code blocks. I allways use brackets even
> for one instruction if's. Hence, when the macro required a code block I
> just used brackets (it was the Microsoft compiler though, might be
> different from GCC).
>
> Thanks,
> Duarte
More information about the Oisf-devel
mailing list