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

Daniel Stone daniel at fooishbar.org
Wed Nov 16 15:50:58 UTC 2016


Hi,

On 10 August 2016 at 09:31, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> 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:
>> > 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)

Additionally ... why do we need an int32_t -> int cast? int will not
be less than 32 bits on any system we build on. Given that, INT_MAX
can surely never be smaller than the range of int32_t, so the test
seems entirely superfluous too.

Cheers,
Daniel


More information about the wayland-devel mailing list