EXT: [PATCH] log: improve handling of use-before-init

Pekka Paalanen ppaalanen at gmail.com
Mon May 28 13:40:45 UTC 2018


On Mon, 7 May 2018 06:23:07 +0000
"Ray, Ian (GE Healthcare)" <ian.ray at ge.com> wrote:

> > On 4 May 2018, at 17.26, Matt Hoosier <matt.hoosier at gmail.com> wrote:
> > 
> > Rather than segfaulting by attempting to traverse an initially
> > null log handler pointer, explicitly print a message and abort.
> > 
> > Signed-off-by: Matt Hoosier <matt.hoosier at gmail.com>  
> 
> Nice improvement!
> 
> Reviewed-by: Ian Ray <ian.ray at ge.com>
> 

Pushed with a small style fix:
   577b3464..74742e05  master -> master

> 
> > ---
> > libweston/log.c | 22 ++++++++++++++++++++--
> > 1 file changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libweston/log.c b/libweston/log.c
> > index 7d99a95d..c21f25e9 100644
> > --- a/libweston/log.c
> > +++ b/libweston/log.c
> > @@ -36,8 +36,26 @@
> > 
> > #include "compositor.h"
> > 
> > -static log_func_t log_handler = 0;
> > -static log_func_t log_continue_handler = 0;
> > +static int default_log_handler(const char *fmt, va_list ap);

Split line.

> > +
> > +static log_func_t log_handler = default_log_handler;
> > +static log_func_t log_continue_handler = default_log_handler;
> > +
> > +/** Sentinel log message handler
> > + *
> > + * This function is used as the default handler for log messages. It
> > + * exists only to issue a noisy reminder to the user that a real handler
> > + * must be installed prior to issuing logging calls. The process is
> > + * immediately aborted after the reminder is printed.
> > + *
> > + * \param fmt The format string. Ignored.
> > + * \param va The variadic argument list. Ignored.
> > + */
> > +static int default_log_handler(const char *fmt, va_list ap)

Split line.

> > +{
> > +        fprintf(stderr, "weston_log_set_handler() must be called before using of weston_log().\n");
> > +        abort();
> > +}
> > 
> > /** Install the log handler
> >  *


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180528/0e4b7018/attachment.sig>


More information about the wayland-devel mailing list