From: Alexander Couzens Date: Wed, 23 Sep 2015 13:04:18 +0000 (+0200) Subject: system: fix undefined behavior in wdt offline check X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c2f1f1908b43f945efc99cb43b49e512ee5d02aa;p=oweals%2Fprocd.git system: fix undefined behavior in wdt offline check watchdog_fd() is returning a char* and not a int. checking against < 0 could lead in undefined behaviour. Signed-off-by: Alexander Couzens --- diff --git a/system.c b/system.c index 82c672e..fb7fbe4 100644 --- a/system.c +++ b/system.c @@ -282,7 +282,7 @@ static int watchdog_set(struct ubus_context *ctx, struct ubus_object *obj, if (tb[WDT_STOP]) watchdog_set_stopped(blobmsg_get_bool(tb[WDT_STOP])); - if (watchdog_fd() < 0) + if (watchdog_fd() == NULL) status = "offline"; else if (watchdog_get_stopped()) status = "stopped";