Re: Debug levels

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Wed, 29 Aug 2001 09:09:31 +0200

"Chemolli Francesco (USI)" wrote:

> > Looks fine except that it is missing a set of paranteses
> > around LEVEL. May be
> > required in case LEVEL is an expression.
>
> It doesn't appear to be the case right now, or it wouldn't compile I think.
> That patch is suboptimal in such a case though, because if the
> test is not constant it won't be optimzied away, and thus it would
> be worse than it is now.
> The attached patch on the other hand should be fine in the same scenario.

I think you got the condition completely inverted. The statement should be filtered
out if the level is greater than max OR greater than the section debuglevel.

#define debug(SECTION, LEVEL) \
        ((LEVEL) > MAX_DEBUG_LEVEL || (_db_level = (LEVEL)) > debugLevels[SECTION])
? (void) 0 : _db_print

And Robert, the original patch design not only did not optimize away statements
where LEVEL is not constant, it also made the expression more complex even if a max
level wasn't configured thus being somewhat counterproductive.

--
Henrik
Received on Wed Aug 29 2001 - 01:15:44 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:16 MST