From d1ad89534aa51f9762c8b3f4da8b9765f4545002 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 1 Oct 2019 16:24:55 -0700 Subject: [PATCH] liblog: remove more endianness functions And fix a mistake from the earlier CL. Bug: 141962035 Test: liblog-unit-tests Change-Id: Id41c47e760f79c0e8bdea54f3644752e2bf7494e --- liblog/log_event_list.cpp | 26 ++++---------------------- liblog/pmsg_writer.cpp | 2 +- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/liblog/log_event_list.cpp b/liblog/log_event_list.cpp index f148ef345..18ea93056 100644 --- a/liblog/log_event_list.cpp +++ b/liblog/log_event_list.cpp @@ -176,13 +176,6 @@ int android_log_write_list_begin(android_log_context ctx) { return 0; } -static inline void copy4LE(uint8_t* buf, uint32_t val) { - buf[0] = val & 0xFF; - buf[1] = (val >> 8) & 0xFF; - buf[2] = (val >> 16) & 0xFF; - buf[3] = (val >> 24) & 0xFF; -} - int android_log_write_int32(android_log_context ctx, int32_t value) { size_t needed; android_log_context_internal* context; @@ -201,22 +194,11 @@ int android_log_write_int32(android_log_context ctx, int32_t value) { } context->count[context->list_nest_depth]++; context->storage[context->pos + 0] = EVENT_TYPE_INT; - copy4LE(&context->storage[context->pos + 1], value); + *reinterpret_cast(&context->storage[context->pos + 1]) = value; context->pos += needed; return 0; } -static inline void copy8LE(uint8_t* buf, uint64_t val) { - buf[0] = val & 0xFF; - buf[1] = (val >> 8) & 0xFF; - buf[2] = (val >> 16) & 0xFF; - buf[3] = (val >> 24) & 0xFF; - buf[4] = (val >> 32) & 0xFF; - buf[5] = (val >> 40) & 0xFF; - buf[6] = (val >> 48) & 0xFF; - buf[7] = (val >> 56) & 0xFF; -} - int android_log_write_int64(android_log_context ctx, int64_t value) { size_t needed; android_log_context_internal* context; @@ -235,7 +217,7 @@ int android_log_write_int64(android_log_context ctx, int64_t value) { } context->count[context->list_nest_depth]++; context->storage[context->pos + 0] = EVENT_TYPE_LONG; - copy8LE(&context->storage[context->pos + 1], value); + *reinterpret_cast(&context->storage[context->pos + 1]) = value; context->pos += needed; return 0; } @@ -267,7 +249,7 @@ int android_log_write_string8_len(android_log_context ctx, const char* value, si } context->count[context->list_nest_depth]++; context->storage[context->pos + 0] = EVENT_TYPE_STRING; - copy4LE(&context->storage[context->pos + 1], len); + *reinterpret_cast(&context->storage[context->pos + 1]) = len; if (len) { memcpy(&context->storage[context->pos + 5], value, len); } @@ -299,7 +281,7 @@ int android_log_write_float32(android_log_context ctx, float value) { ivalue = *(uint32_t*)&value; context->count[context->list_nest_depth]++; context->storage[context->pos + 0] = EVENT_TYPE_FLOAT; - copy4LE(&context->storage[context->pos + 1], ivalue); + *reinterpret_cast(&context->storage[context->pos + 1]) = ivalue; context->pos += needed; return 0; } diff --git a/liblog/pmsg_writer.cpp b/liblog/pmsg_writer.cpp index 69720ed65..202b0fe32 100644 --- a/liblog/pmsg_writer.cpp +++ b/liblog/pmsg_writer.cpp @@ -100,7 +100,7 @@ static int pmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, siz return -EINVAL; } - if (SNET_EVENT_LOG_TAG != *static_cast(vec[0].iov_base)) { + if (SNET_EVENT_LOG_TAG != *static_cast(vec[0].iov_base)) { return -EPERM; } }