RE: Debug levels

From: Chemolli Francesco (USI) <ChemolliF@dont-contact.us>
Date: Wed, 29 Aug 2001 09:52:28 +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

Uhm, yes. I missed the point that it's the "else" branch being taken.
'f course, it could also be written as

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

simple bool math.

> 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.

Only where the level was not constant. I'm not aware of such instances,
but that doesn't mean they might not appear in the future.

-- 
	/kinkie 
Received on Wed Aug 29 2001 - 11:26:23 MDT

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