This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add --foreground option for nscd


On Wednesday, May 09, 2012 17:24:10 Pedro Alves wrote:
> On 05/09/2012 03:33 PM, Andreas Jaeger wrote:
> >  int disabled_group;
> > 
> > -int go_background = 1;
> > +
> > +enum
> > +{
> > +  /* Running in foreground but otherwise behave like a daemon,
> > +     i.e., detach from terminal and use syslog.  */
> > +  RUN_FOREGROUND,
> > +  /* Running in background as daemon.  */
> > +  RUN_DAEMONIZE,
> > +  /* Run in foreground in debug mode.  */
> > +  RUN_DEBUG
> > +};
> > +static int run_mode = RUN_DAEMONIZE;
> 
> Since you have an enum, why not make the variable have enum type too?
> If you don't want to give the enum a name/tag, there's always:
> 
> static enum
>  {
>    ...
>  } run_mode = RUN_DAEMONIZE;
> 
> As principle, making the type an enum makes the code easier to debug,
> as "(gdb) print run_mode" then outputs the enum value (RUN_DAEMONIZE,
> etc.) instead of the underlying integer (0, 1, etc.).
> 
> > -  /* Behave like a daemon.  */
> > -  if (go_background)
> > +  if ((run_mode == RUN_DAEMONIZE) || (run_mode == RUN_FOREGROUND))
> 
> GNU style is against such redundant parenthesis.

Thanks, I'll send a cleanup patch later,

Andreas
-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]