[PATCH weston v4 5/5] Switch to use safe_strtoint instead of strtol

Pekka Paalanen ppaalanen at gmail.com
Wed Aug 10 08:31:49 UTC 2016


On Tue, 9 Aug 2016 11:12:33 -0700
Bryce Harrington <bryce at osg.samsung.com> wrote:

> On Mon, Aug 08, 2016 at 02:55:14PM +0300, Pekka Paalanen wrote:
> > On Wed,  3 Aug 2016 17:40:52 -0700
> > Bryce Harrington <bryce at osg.samsung.com> wrote:
> >   
> > > Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> > > Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> > > ---
> > >  compositor/main.c           |  7 +++----
> > >  compositor/systemd-notify.c |  9 +++------
> > >  libweston/compositor.c      |  9 +++------
> > >  libweston/libbacklight.c    | 11 +++++------
> > >  shared/config-parser.c      |  7 ++-----
> > >  shared/option-parser.c      |  5 ++---
> > >  xwayland/launcher.c         |  7 +++----
> > >  7 files changed, 21 insertions(+), 34 deletions(-)
> > >   
> >   
> > > diff --git a/compositor/systemd-notify.c b/compositor/systemd-notify.c
> > > index 6104124..49e51f4 100644
> > > --- a/compositor/systemd-notify.c
> > > +++ b/compositor/systemd-notify.c
> > > @@ -25,12 +25,13 @@
> > >  
> > >  #include "config.h"
> > >  
> > > -#include <errno.h>
> > >  #include <stdlib.h>
> > >  #include <systemd/sd-daemon.h>
> > >  #include <sys/socket.h>
> > >  #include <wayland-server.h>
> > > +
> > >  #include "shared/helpers.h"
> > > +#include "shared/string-helpers.h"
> > >  #include "shared/zalloc.h"
> > >  #include "compositor.h"
> > >  
> > > @@ -116,7 +117,6 @@ WL_EXPORT int
> > >  module_init(struct weston_compositor *compositor,
> > >  	    int *argc, char *argv[])
> > >  {
> > > -	char *tail;
> > >  	char *watchdog_time_env;
> > >  	struct wl_event_loop *loop;
> > >  	long watchdog_time_conv;
> > > @@ -140,13 +140,10 @@ module_init(struct weston_compositor *compositor,
> > >  	 * by systemd to transfer 'WatchdogSec' watchdog timeout
> > >  	 * setting from service file.*/
> > >  	watchdog_time_env = getenv("WATCHDOG_USEC");
> > > -
> > >  	if (!watchdog_time_env)
> > >  		return 0;
> > >  
> > > -	errno = 0;
> > > -	watchdog_time_conv = strtol(watchdog_time_env, &tail, 10);
> > > -	if (errno != 0 || tail == watchdog_time_env || *tail != '\0')
> > > +	if (!safe_strtoint(watchdog_time_env, &watchdog_time_conv))
> > >  		return 0;
> > >  
> > >  	/* Convert 'WATCHDOG_USEC' to milliseconds and notify  
> > 
> > Hi,
> > 
> > there's a new warning:
> > 
> > /home/pq/git/weston/compositor/systemd-notify.c: In function ‘module_init’:
> > /home/pq/git/weston/compositor/systemd-notify.c:146:40: warning: passing argument 2 of ‘safe_strtoint’ from incompatible pointer type
> >   if (!safe_strtoint(watchdog_time_env, &watchdog_time_conv))
> >                                         ^
> > In file included from /home/pq/git/weston/compositor/systemd-notify.c:34:0:
> > /home/pq/git/weston/shared/string-helpers.h:45:1: note: expected ‘int32_t *’ but argument is of type ‘long int *’
> >  safe_strtoint(const char *str, int32_t *value)
> >  ^
> > 
> > Please CC me if you want me to test a patch for this. I suppose int32_t
> > should be fine?  
> 
> attached

Hi Bryce,

the patch results in:

  CC       compositor/systemd_notify_la-systemd-notify.lo
/home/pq/git/weston/compositor/systemd-notify.c: In function ‘module_init’:
/home/pq/git/weston/compositor/systemd-notify.c:154:11: error: ‘watchdog_time_conf’ undeclared (first use in this function)
  else if (watchdog_time_conf > INT_MAX)
           ^
/home/pq/git/weston/compositor/systemd-notify.c:154:11: note: each undeclared identifier is reported only once for each function it appears in
/home/pq/git/weston/compositor/systemd-notify.c:154:32: error: ‘INT_MAX’ undeclared (first use in this function)
  else if (watchdog_time_conf > INT_MAX)
                                ^

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


More information about the wayland-devel mailing list