From 469a3ddad4fc39451250b3bf5b8417c3ca930289 Mon Sep 17 00:00:00 2001 From: Christian Balster Date: Mon, 15 Jun 2015 21:10:09 +0200 Subject: espresso-common: libsensors: fix buffer overflows long/int can't hold timestamp values in ns, use int64_t instead Change-Id: Id3e08a45aa556d8858b8b57d03c3b737e999772d --- libsensors/yas_orientation.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libsensors/yas_orientation.c') diff --git a/libsensors/yas_orientation.c b/libsensors/yas_orientation.c index 3668d8b..c14ed72 100644 --- a/libsensors/yas_orientation.c +++ b/libsensors/yas_orientation.c @@ -191,13 +191,12 @@ int yas_orientation_deactivate(struct piranha_sensors_handlers *handlers) return 0; } -int yas_orientation_set_delay(struct piranha_sensors_handlers *handlers, long int delay) +int yas_orientation_set_delay(struct piranha_sensors_handlers *handlers, int64_t delay) { struct yas_orientation_data *data; - int d; int rc; - ALOGD("%s(%p, %ld)", __func__, handlers, delay); + ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); if (handlers == NULL || handlers->data == NULL) return -EINVAL; @@ -214,11 +213,11 @@ int yas_orientation_set_delay(struct piranha_sensors_handlers *handlers, long in data->magnetic_sensor->set_delay(data->magnetic_sensor, delay); if (delay < 10000000) - d = 10; + delay = 10; else - d = delay / 1000000; + delay /= 1000000; - rc = sysfs_value_write(data->path_delay, d); + rc = sysfs_value_write(data->path_delay, delay); if (rc < 0) { ALOGE("%s: Unable to write sysfs value", __func__); return -1; -- cgit v1.1