lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Stats and code readability


From: Zschocke, Florian
Subject: [lwip-users] Stats and code readability
Date: Wed, 18 Jun 2003 14:46:41 +0200

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.





reply via email to

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