summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarout Hedeshian <harouth@codeaurora.org>2015-07-22 14:53:41 -0600
committerHarout Hedeshian <harouth@codeaurora.org>2015-07-22 16:32:17 -0600
commit0abce0065f60c8a4d1f445196105a2483ecbc2ef (patch)
tree2be41ff80505e1b66f4101fa2a486b8abe4aab11
parent407b0fd9b8f5f3518bdfa4684a01aae25511db4d (diff)
downloadandroid_vendor_qcom_opensource_dataservices-0abce0065f60c8a4d1f445196105a2483ecbc2ef.tar.gz
android_vendor_qcom_opensource_dataservices-0abce0065f60c8a4d1f445196105a2483ecbc2ef.tar.bz2
android_vendor_qcom_opensource_dataservices-0abce0065f60c8a4d1f445196105a2483ecbc2ef.zip
datatop: switch to PRId64/PRIu64 instead of %llu/%lld
Replaced lld and llu with PRId64/PRIu64 to allow cross-platform printing of 64-bit integers with printf. Also set C standard to C99 in order for these macros to compile cleanly. Change-Id: I0e39c41f931c92d3e554c2256fdb9d3bcef6d9b9
-rw-r--r--datatop/src/Android.mk2
-rw-r--r--datatop/src/datatop_helpers.c33
-rw-r--r--datatop/src/datatop_meminfo_file_poll.c4
3 files changed, 13 insertions, 26 deletions
diff --git a/datatop/src/Android.mk b/datatop/src/Android.mk
index 51d062a..6b93c9f 100644
--- a/datatop/src/Android.mk
+++ b/datatop/src/Android.mk
@@ -18,7 +18,7 @@ LOCAL_SRC_FILES += datatop_str.c
LOCAL_SRC_FILES += datatop_sys_snap.c
LOCAL_SRC_FILES += datatop_value_only_poll.c
-LOCAL_CFLAGS := -Wall -Wextra -Werror -pedantic
+LOCAL_CFLAGS := -Wall -Wextra -Werror -pedantic -std=c99
LOCAL_CFLAGS += -DVERSION="\"1.0.4"\"
LOCAL_CFLAGS += -DHAVE_STRL_FUNCTIONS
LOCAL_CFLAGS += -D _BSD_SOURCE
diff --git a/datatop/src/datatop_helpers.c b/datatop/src/datatop_helpers.c
index 55fbb09..325b824 100644
--- a/datatop/src/datatop_helpers.c
+++ b/datatop/src/datatop_helpers.c
@@ -38,6 +38,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
@@ -84,11 +85,11 @@ static int dtop_format_dp_values(struct dtop_data_point *dp, FILE *fw)
{
switch (dp->type) {
case DTOP_ULONG:
- if (fprintf(fw, "%lu", dp->data.d_ulong) < 0)
+ if (fprintf(fw, "%"PRIu64, dp->data.d_ulong) < 0)
return FILE_ERROR;
break;
case DTOP_LONG:
- if (fprintf(fw, "%ld", dp->data.d_long) < 0)
+ if (fprintf(fw, "%"PRId64, dp->data.d_long) < 0)
return FILE_ERROR;
break;
case DTOP_UINT:
@@ -191,11 +192,7 @@ static void dtop_handle_dp_type_for_snapshot(
- (int64_t)dp.initial_data.d_ulong;
if (int64 != 0) {
dtop_format_text_for_snapshot(dpset, dp);
- #if (__SIZEOF_LONG__ == 4)
- printf("%lld\n", int64);
- #elif (__SIZEOF_LONG__ == 8)
- printf("%ld\n", int64);
- #endif
+ printf("%"PRId64"\n", int64);
}
break;
@@ -205,11 +202,7 @@ static void dtop_handle_dp_type_for_snapshot(
- (int64_t)dp.initial_data.d_long;
if (int64 != 0) {
dtop_format_text_for_snapshot(dpset, dp);
- #if (__SIZEOF_LONG__ == 4)
- printf("%lld\n", int64);
- #elif (__SIZEOF_LONG__ == 8)
- printf("%ld\n", int64);
- #endif
+ printf("%"PRId64"\n", int64);
}
break;
@@ -218,11 +211,7 @@ static void dtop_handle_dp_type_for_snapshot(
- (int64_t)dp.initial_data.d_uint;
if (int64 != 0) {
dtop_format_text_for_snapshot(dpset, dp);
- #if (__SIZEOF_LONG__ == 4)
- printf("%lld\n", int64);
- #elif (__SIZEOF_LONG__ == 8)
- printf("%ld\n", int64);
- #endif
+ printf("%"PRId64"\n", int64);
}
break;
@@ -231,11 +220,7 @@ static void dtop_handle_dp_type_for_snapshot(
- (int64_t)dp.initial_data.d_int;
if (int64 != 0) {
dtop_format_text_for_snapshot(dpset, dp);
- #if (__SIZEOF_LONG__ == 4)
- printf("%lld\n", int64);
- #elif (__SIZEOF_LONG__ == 8)
- printf("%ld\n", int64);
- #endif
+ printf("%"PRId64"\n", int64);
}
break;
}
@@ -332,14 +317,14 @@ void dtop_store_dp(struct dtop_data_point *dp, const char *str)
{
switch (dp->type) {
case DTOP_ULONG:
- sscanf(str, "%lu", &(dp->data.d_ulong));
+ sscanf(str, "%"PRIu64, &(dp->data.d_ulong));
if (dp->initial_data_populated == NOT_POPULATED) {
dp->initial_data.d_ulong = dp->data.d_ulong;
dp->initial_data_populated = POPULATED;
}
break;
case DTOP_LONG:
- sscanf(str, "%ld", &(dp->data.d_long));
+ sscanf(str, "%"PRId64, &(dp->data.d_long));
if (dp->initial_data_populated == NOT_POPULATED) {
dp->initial_data.d_long = dp->data.d_long;
dp->initial_data_populated = POPULATED;
diff --git a/datatop/src/datatop_meminfo_file_poll.c b/datatop/src/datatop_meminfo_file_poll.c
index bef1c5d..078b825 100644
--- a/datatop/src/datatop_meminfo_file_poll.c
+++ b/datatop/src/datatop_meminfo_file_poll.c
@@ -36,8 +36,10 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <stdlib.h>
+#include <inttypes.h>
#include "datatop_interface.h"
#include "datatop_fileops.h"
#include "datatop_str.h"
@@ -142,7 +144,7 @@ int dtop_meminfo_poll(struct dtop_data_point_gatherer *dpg)
for (j = 0; j < dpg->data_points_len; j++) {
i = dt_find_dict_idx(dpg->data_points[j].name, &dict);
if (i >= 0 && i < dict.max) {
- sscanf(dict.val[i], "%lu",
+ sscanf(dict.val[i], "%" PRIu64,
&(dpg->data_points[i].data.d_ulong));
dpg->data_points[i].data.d_ulong *= 1024;
if (dpg->data_points[i].