Useless loop?

Christopher R. Hertel crh at nts.umn.edu
Thu Nov 4 19:05:06 GMT 1999


Yes, it will be a do-nothing counter from 0 to ngroups-1.

The fix would be:

if( DEBUGLVL( 3 ) )
  {
  dbgtext( %s is in %d groups: ", user, ngroups );
  for( i = 0; i < ngroups; i++ )
    dbgtext( "%s%d", (i ? ", " : ""), (int)groups[i] );
  dgbtext( "\n" );
  }

The above should produce the same result but will only check the debug
level once (instead of ngroups+2 times) and will bypass the loop entirely
if the debug level is set low enough. 

I have not tested the above code sample, but it should be reasonably 
close to correct.

Chris -)-----

> I'm not a programmer.  I don't even pretend to be one.  But every now
> and then I get the urge to look at some source to try and figure out
> how things work...
> 
> During one of these urges, I was browsing the 2.0.5a source, and in
> smbd/password.c, function setup_groups(), I see this:
> 
> DEBUG( 3, ( "%s is in %d groups: ", user, ngroups ) );
> for (i = 0; i < ngroups; i++ )
> {
>         DEBUG( 3, ( "%s%d", (i ? ", " : ""), (int)groups[i] ) );
> }
> DEBUG( 3, ( "\n" ) );
> 
> If my log level <3 in smb.conf, then this loops for no apparent reason,
> right?  If was trying to achieve better performance by reducing the logging
> level, this will still impact me (well, no logging occurs, but smbd will
> loop and, essentially do nothing in the loop)...
> 
> .. or am I missing something glaringly obvious here?
> 
> (ps - I'm not subscribed to samba-technical).
> 


-- 
             -- I have a shoehorn, the kind with teeth. --
                                  ---
Christopher R. Hertel -)-----                   University of Minnesota
crh at nts.umn.edu              Networking and Telecommunications Services


More information about the samba-technical mailing list