From 8470dad24f17f6e13aab7f723821a2acb318baad Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Fri, 6 Mar 2015 20:42:57 +0000 Subject: [PATCH] Revert "liblog: logprint use " This reverts commit 66bfc5ccbda1c36923230b8dea36e86e8ac62d67. Bug: 19634248 Change-Id: I7c4851a247042193674f226fd0d5c5663e8074c7 --- liblog/logprint.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/liblog/logprint.c b/liblog/logprint.c index b5145fd5d..7ba4c8e78 100644 --- a/liblog/logprint.c +++ b/liblog/logprint.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -416,6 +415,27 @@ int android_log_processLogBuffer(struct logger_entry *buf, return 0; } +/* + * Extract a 4-byte value from a byte stream. + */ +static inline uint32_t get4LE(const uint8_t* src) +{ + return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); +} + +/* + * Extract an 8-byte value from a byte stream. + */ +static inline uint64_t get8LE(const uint8_t* src) +{ + uint32_t low, high; + + low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); + high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24); + return ((long long) high << 32) | (long long) low; +} + + /* * Recursively convert binary log data to printable form. * @@ -453,7 +473,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 4) return -1; - ival = le32toh(*((int32_t *)eventData)); + ival = get4LE(eventData); eventData += 4; eventDataLen -= 4; @@ -474,7 +494,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 8) return -1; - lval = le64toh(*((int64_t *)eventData)); + lval = get8LE(eventData); eventData += 8; eventDataLen -= 8; @@ -495,7 +515,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 4) return -1; - strLen = le32toh(*((int32_t *)eventData)); + strLen = get4LE(eventData); eventData += 4; eventDataLen -= 4; @@ -610,7 +630,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf, inCount = buf->len; if (inCount < 4) return -1; - tagIndex = le32toh(*((int32_t *)eventData)); + tagIndex = get4LE(eventData); eventData += 4; inCount -= 4;