liblog: add -Wall,-Wextra and do related clean-up.
Test: build
Change-Id: I3b33f2b896cb8bf7ad9edf110d1739d559028282
diff --git a/liblog/Android.bp b/liblog/Android.bp
index c38d8cd..588089b 100644
--- a/liblog/Android.bp
+++ b/liblog/Android.bp
@@ -108,7 +108,9 @@
},
cflags: [
+ "-Wall",
"-Werror",
+ "-Wextra",
// This is what we want to do:
// liblog_cflags := $(shell \
// sed -n \
diff --git a/liblog/log_event_list.cpp b/liblog/log_event_list.cpp
index b1b527c..8ffbc45 100644
--- a/liblog/log_event_list.cpp
+++ b/liblog/log_event_list.cpp
@@ -88,7 +88,6 @@
android_log_context create_android_log_parser(const char* msg, size_t len) {
android_log_context_internal* context;
- size_t i;
context =
static_cast<android_log_context_internal*>(calloc(1, sizeof(android_log_context_internal)));
diff --git a/liblog/logger_write.cpp b/liblog/logger_write.cpp
index 4fbab4b..aef9e04 100644
--- a/liblog/logger_write.cpp
+++ b/liblog/logger_write.cpp
@@ -39,13 +39,6 @@
static int __write_to_log_init(log_id_t, struct iovec* vec, size_t nr);
static int (*write_to_log)(log_id_t, struct iovec* vec, size_t nr) = __write_to_log_init;
-/*
- * This is used by the C++ code to decide if it should write logs through
- * the C code. Basically, if /dev/socket/logd is available, we're running in
- * the simulator rather than a desktop tool and want to use the device.
- */
-static enum { kLogUninitialized, kLogNotAvailable, kLogAvailable } g_log_status = kLogUninitialized;
-
static int check_log_uid_permissions() {
#if defined(__ANDROID__)
uid_t uid = __android_log_uid();
@@ -104,22 +97,6 @@
}
}
-extern "C" int __android_log_dev_available() {
- struct android_log_transport_write* node;
-
- if (list_empty(&__android_log_transport_write)) {
- return kLogUninitialized;
- }
-
- write_transport_for_each(node, &__android_log_transport_write) {
- __android_log_cache_available(node);
- if (node->logMask) {
- return kLogAvailable;
- }
- }
- return kLogNotAvailable;
-}
-
#if defined(__ANDROID__)
static atomic_uintptr_t tagMap;
#endif
@@ -228,13 +205,6 @@
return ret;
}
-/*
- * Extract a 4-byte value from a byte stream. le32toh open coded
- */
-static inline uint32_t get4LE(const uint8_t* src) {
- return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
-}
-
static int __write_to_log_daemon(log_id_t log_id, struct iovec* vec, size_t nr) {
struct android_log_transport_write* node;
int ret, save_errno;
@@ -302,7 +272,7 @@
}
}
if (m && (m != (EventTagMap*)(uintptr_t)-1LL)) {
- tag = android_lookupEventTag_len(m, &len, get4LE(static_cast<uint8_t*>(vec[0].iov_base)));
+ tag = android_lookupEventTag_len(m, &len, *static_cast<uint32_t*>(vec[0].iov_base));
}
ret = __android_log_is_loggable_len(ANDROID_LOG_INFO, tag, len, ANDROID_LOG_VERBOSE);
if (f) { /* local copy marked for close */
diff --git a/liblog/logprint.cpp b/liblog/logprint.cpp
index 3a54445..939c1b3 100644
--- a/liblog/logprint.cpp
+++ b/liblog/logprint.cpp
@@ -291,8 +291,10 @@
return 1;
}
+#ifndef __MINGW32__
static const char tz[] = "TZ";
static const char utc[] = "UTC";
+#endif
/**
* Returns FORMAT_OFF on invalid string
@@ -1189,6 +1191,7 @@
return p - begin;
}
+#ifdef __ANDROID__
static char* readSeconds(char* e, struct timespec* t) {
unsigned long multiplier;
char* p;
@@ -1229,7 +1232,6 @@
return (long long)now->tv_sec * NS_PER_SEC + now->tv_nsec;
}
-#ifdef __ANDROID__
static void convertMonotonic(struct timespec* result, const AndroidLogEntry* entry) {
struct listnode* node;
struct conversionList {
diff --git a/liblog/pmsg_reader.cpp b/liblog/pmsg_reader.cpp
index 81563bc..005fec8 100644
--- a/liblog/pmsg_reader.cpp
+++ b/liblog/pmsg_reader.cpp
@@ -130,7 +130,6 @@
ssize_t ret;
off_t current, next;
uid_t uid;
- struct android_log_logger* logger;
struct __attribute__((__packed__)) {
android_pmsg_log_header_t p;
android_log_header_t l;