[PATCH weston] weston-launch: use custom error function

Murray Calavera murray.calavera at gmail.com
Fri Sep 30 10:36:24 UTC 2016


On 30 September 2016 at 11:10, Eric Engestrom <eric.engestrom at imgtec.com>
wrote:

> On Thu, Sep 29, 2016 at 09:26:16PM +0100, Murray Calavera wrote:
> > error.h is a gnu extension and not available in other
> > popular libcs like musl. This patch provides a replacement.
> >
> > Signed-off-by: Murray Calavera <murray.calavera at gmail.com>
>
> How did you test this? For me, `CC=musl-gcc ./autogen.sh` stops on:
>   [...]
>   checking for library containing pam_open_session... no
>   configure: error: weston-launch requires pam
>

​Have you got libpam installed?
I don't see how this patch could have affected the configure,
does it configure without this patch?​

>
> The code looks good though (with one nit-pick), so even if I couldn't
> test it, it is:
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
>
> > ---
> >  libweston/weston-launch.c | 20 +++++++++++++++++++-
> >  1 file changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
> > index 140fde1..84f7d60 100644
> > --- a/libweston/weston-launch.c
> > +++ b/libweston/weston-launch.c
> > @@ -33,7 +33,6 @@
> >  #include <poll.h>
> >  #include <errno.h>
> >
> > -#include <error.h>
> >  #include <getopt.h>
> >
> >  #include <sys/types.h>
> > @@ -112,6 +111,25 @@ struct weston_launch {
> >
> >  union cmsg_data { unsigned char b[4]; int fd; };
> >
> > +static void
> > +error(int status, int errnum, const char *msg, ...)
> > +{
> > +     va_list args;
> > +
> > +     fputs("weston-launch: ", stderr);
> > +     va_start(args, msg);
> > +     vfprintf(stderr, msg, args);
> > +     va_end(args);
> > +
> > +     if (errnum)
> > +             fprintf(stderr, ": %s\n", strerror(errnum));
> > +     else
> > +             fputc('\n', stderr);
>
> Why not `fprintf(stderr, "\n");`?
> While fputc() is enough since this is a single char, the use of
> a different function here looks... odd.
>

​As you said, because I'm not printing formatted data
there is no need to use printf.​
However if the consensus here is to use printf even
when not needed, I can change that.

>
> > +
> > +     if (status)
> > +             exit(status);
> > +}
> > +
> >  static gid_t *
> >  read_groups(void)
> >  {
> > --
> > 2.10.0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160930/c4f2d770/attachment.html>


More information about the wayland-devel mailing list