From fc862f3a4c433c67605f12ad2d9addc6fc1bc831 Mon Sep 17 00:00:00 2001 From: Dheeraj CVR Date: Thu, 11 Jun 2015 16:44:25 +0400 Subject: libsensors: switch to portable typedefs to match callbacks Using a strict basetype only coding style is not a good idea especially when we are dealing with callbacks which use portable typedef like int64_t. This kind of coding style would most likely end up in overflows at various places especially when dealing with timestamps and sensor delays which are caused when typecasting datatypes of different size. Switch to portable typedefs and get rid of "long". Change-Id: I75b9cace7602345dba9095f046292e6d4db07df4 --- libsensors/lps331ap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libsensors/lps331ap.c') diff --git a/libsensors/lps331ap.c b/libsensors/lps331ap.c index 5c3007b..a8ef55a 100644 --- a/libsensors/lps331ap.c +++ b/libsensors/lps331ap.c @@ -150,13 +150,12 @@ int lps331ap_deactivate(struct smdk4x12_sensors_handlers *handlers) return 0; } -int lps331ap_set_delay(struct smdk4x12_sensors_handlers *handlers, long int delay) +int lps331ap_set_delay(struct smdk4x12_sensors_handlers *handlers, int64_t delay) { struct lps331ap_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; @@ -164,11 +163,11 @@ int lps331ap_set_delay(struct smdk4x12_sensors_handlers *handlers, long int dela data = (struct lps331ap_data *) handlers->data; if (delay < 10000000) - d = 10; + delay = 10; else - d = delay / 1000000; + delay = 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