On Mon, Aug 08, 2016 at 02:55:14PM +0300, Pekka Paalanen wrote: > On Wed, 3 Aug 2016 17:40:52 -0700 > Bryce Harrington <[email protected]> wrote: > > > Reviewed-by: Eric Engestrom <[email protected]> > > Signed-off-by: Bryce Harrington <[email protected]> > > --- > > 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
>From 8620b0e442543421f20191b3f8d7b46a057ceecb Mon Sep 17 00:00:00 2001 From: Bryce Harrington <[email protected]> Date: Tue, 9 Aug 2016 11:11:05 -0700 Subject: [PATCH weston] systemd-notify: Fix type warning in string conversion Signed-off-by: Bryce Harrington <[email protected]> --- compositor/systemd-notify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compositor/systemd-notify.c b/compositor/systemd-notify.c index 49e51f4..dfe259e 100644 --- a/compositor/systemd-notify.c +++ b/compositor/systemd-notify.c @@ -119,7 +119,7 @@ module_init(struct weston_compositor *compositor, { char *watchdog_time_env; struct wl_event_loop *loop; - long watchdog_time_conv; + int32_t watchdog_time_conv; struct systemd_notifier *notifier; notifier = zalloc(sizeof *notifier); @@ -151,8 +151,10 @@ module_init(struct weston_compositor *compositor, watchdog_time_conv /= 1000 * 2; if (watchdog_time_conv <= 0) return 0; + else if (watchdog_time_conf > INT_MAX) + return -1; - notifier->watchdog_time = watchdog_time_conv; + notifier->watchdog_time = (int)watchdog_time_conv; loop = wl_display_get_event_loop(compositor->wl_display); notifier->watchdog_source = -- 1.9.1
_______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
