Re: [PATCH] ksmbd-tools: Standardize exit codes

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

 



Le jeudi 04 novembre 2021 à 08:26 +0900, Namjae Jeon a écrit :
> 2021-11-04 0:10 GMT+09:00, Guillaume Castagnino <casta@xxxxxxxxxx>:
> > In case of success, EXIT_SUCCESS must be returned by the control
> > binary
> > This standard behaviour is expected for example for the unit file
> > 
> > Signed-off-by: Guillaume Castagnino <casta@xxxxxxxxxx>
> > ---
> >  control/control.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/control/control.c b/control/control.c
> > index 5b86355..5ff2780 100644
> > --- a/control/control.c
> > +++ b/control/control.c
> > @@ -43,7 +43,7 @@ static int ksmbd_control_shutdown(void)
> > 
> >         ret = write(fd, "hard", 4);
> >         close(fd);
> > -       return ret;
> > +       return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
> Shouldn't we also return such a return for open() failures?
> 

In case of open error, it already returns something != 0 (-1) in every
cases. So for me it’s less an an issue. But it would probably be better
if it’s EXIT_FAILURE indeed.

I will submit a new patch

Regards,


> >  }
> > 
> >  static int ksmbd_control_show_version(void)
> > @@ -61,7 +61,7 @@ static int ksmbd_control_show_version(void)
> >         close(fd);
> >         if (ret != -1)
> >                 pr_info("ksmbd version : %s\n", ver);
> > -       return ret;
> > +       return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
> Ditto.
> >  }
> > 
> >  static int ksmbd_control_debug(char *comp)
> > @@ -85,7 +85,7 @@ static int ksmbd_control_debug(char *comp)
> >         pr_info("%s\n", buf);
> >  out:
> >         close(fd);
> > -       return ret;
> > +       return ret != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
> Ditto.
> >  }
> > 
> >  int main(int argc, char *argv[])
> > @@ -104,7 +104,7 @@ int main(int argc, char *argv[])
> >         while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
> >                 switch (c) {
> >                 case 's':
> > -                       ksmbd_control_shutdown();
> > +                       ret = ksmbd_control_shutdown();
> >                         break;
> >                 case 'd':
> >                         ret = ksmbd_control_debug(optarg);
> > --
> > 2.33.1
> > 
> > 



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux