Switch to use safe_strtoint instead of strtol
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
diff --git a/libweston/libbacklight.c b/libweston/libbacklight.c
index 59f4e44..4bbc6db 100644
--- a/libweston/libbacklight.c
+++ b/libweston/libbacklight.c
@@ -44,13 +44,14 @@
#include <string.h>
#include <errno.h>
+#include "shared/string-helpers.h"
+
static long backlight_get(struct backlight *backlight, char *node)
{
char buffer[100];
char *path;
- char *end;
- int fd;
- long value, ret;
+ int fd, value;
+ long ret;
if (asprintf(&path, "%s/%s", backlight->path, node) < 0)
return -ENOMEM;
@@ -66,9 +67,7 @@
goto out;
}
- errno = 0;
- value = strtol(buffer, &end, 10);
- if (errno != 0 || end == buffer || *end != '\0') {
+ if (!safe_strtoint(buffer, &value)) {
ret = -1;
goto out;
}