liblog: add -Wall,-Wextra and do related clean-up.

Test: build
Change-Id: I3b33f2b896cb8bf7ad9edf110d1739d559028282
This commit is contained in:
Tom Cherry 2019-09-30 12:58:55 -07:00
parent 2c392b6d0a
commit 7d045f6b74
5 changed files with 6 additions and 34 deletions

View file

@ -108,7 +108,9 @@ cc_library {
},
cflags: [
"-Wall",
"-Werror",
"-Wextra",
// This is what we want to do:
// liblog_cflags := $(shell \
// sed -n \

View file

@ -88,7 +88,6 @@ android_log_context create_android_logger(uint32_t tag) {
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)));

View file

@ -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 @@ static void __android_log_cache_available(struct android_log_transport_write* no
}
}
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 @@ static int __write_to_log_initialize() {
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 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec* vec, size_t nr)
}
}
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 */

View file

@ -291,8 +291,10 @@ int android_log_setPrintFormat(AndroidLogFormat* p_format, AndroidLogPrintFormat
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 @@ size_t convertPrintable(char* p, const char* message, size_t messageLen) {
return p - begin;
}
#ifdef __ANDROID__
static char* readSeconds(char* e, struct timespec* t) {
unsigned long multiplier;
char* p;
@ -1229,7 +1232,6 @@ static long long nsecTimespec(struct timespec* now) {
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 {

View file

@ -130,7 +130,6 @@ static int pmsgRead(struct android_log_logger_list* logger_list,
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;