summaryrefslogtreecommitdiff
path: root/libweston
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2016-08-03 17:40:52 -0700
committerBryce Harrington <bryce@osg.samsung.com>2016-08-06 18:19:22 -0700
commit25a2bdd814ef70df3d2c6cdd4098644a34406510 (patch)
tree41eb2ba35e4a39ba7cb84c6e38374c7cc66da668 /libweston
parent82b9f2baec2aabe659a7470cbdd51331bcd34906 (diff)
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>
Diffstat (limited to 'libweston')
-rw-r--r--libweston/compositor.c9
-rw-r--r--libweston/libbacklight.c11
2 files changed, 8 insertions, 12 deletions
diff --git a/libweston/compositor.c b/libweston/compositor.c
index e9c2a837..b17c76d9 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -58,6 +58,7 @@
#include "presentation-time-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
+#include "shared/string-helpers.h"
#include "shared/timespec-util.h"
#include "git-version.h"
#include "version.h"
@@ -4622,15 +4623,11 @@ compositor_bind(struct wl_client *client,
WL_EXPORT int
weston_environment_get_fd(const char *env)
{
- char *e, *end;
+ char *e;
int fd, flags;
e = getenv(env);
- if (!e)
- return -1;
- errno = 0;
- fd = strtol(e, &end, 10);
- if (errno != 0 || end == e || *end != '\0')
+ if (!e || !safe_strtoint(e, &fd))
return -1;
flags = fcntl(fd, F_GETFD);
diff --git a/libweston/libbacklight.c b/libweston/libbacklight.c
index 59f4e440..4bbc6db4 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 @@ static long backlight_get(struct backlight *backlight, char *node)
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;
}