lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Stats and code readability


From: Ed Sutter
Subject: Re: [lwip-users] Stats and code readability
Date: Wed, 18 Jun 2003 09:16:23 -0400

Florian,
I did something similar to the XXX_STATS macros on one of
the earlier versions of LWIP.  Makes the code a lot more
readable.  Having updated to the latest, I lost those
changes (should have submitted the suggestion a while ago).
So I second this request.

However, I have a question that is most likely going to
further reveal my own stupidity...
I see in several places in the LWIP code the following...

#define MACRO_XYX(var)  do{++var;}while(0)

My question is...
Why do that instead of just doing...

#define MACRO_XYZ(var)  ++var

Is this just a "style" thing, or is there value in
using the upper format instead of the visually simpler
lower format?
Thanks for the spoon feeding!
Ed

"Zschocke, Florian" wrote:
> 
> The code is filles with lines like these:
> 
> #ifdef UDP_STATS
>   ++lwip_stats.udp.xmit;
> #endif /* UDP_STATS */
> 
> Couldn't we instead define macros:
> 
> #if LWIP_STATS
> #  define INC_xxx_STATS(var) do{++var;}while(0)
> #  define DEC_xxx_STATS(var) do{--var;}while(0)
> #  define SET_xxx_STATS(var,val) do{var=(val);}while(0)
> #else
> #  define INC_xxx_STATS(var)
> #  define DEC_xxx_STATS(var)
> #  define SET_xxx_STATS(var,val)
> #endif
> 
> and then simply use lines like this in the code?
> 
> INC_UDP_STATS(lwip_stats.udp.xmit);
> 
> Or maybe even INC_UDP_STATS(xmit); with
> #  define INC_UDP_STATS(var) do{++lwip_stats.udp.var;}while(0)
> 
> I think that would add a lot to code readability, doin away with most of the
> #if xxx_STATS directives in the code.
> 
> Florian.
> 
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/lwip-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]