summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-02-19 13:08:59 -0800
committerMark Salyzyn <salyzyn@google.com>2016-02-19 14:40:16 -0800
commitb525884edb1f8a80a8fc6cad58c69bdacc5bdb90 (patch)
tree5c028ecb73a719100019e75f38dd4058111f1881 /liblog
parentee127f3d6b20c45e90f277d5571260b0250f0349 (diff)
downloadcore-b525884edb1f8a80a8fc6cad58c69bdacc5bdb90.tar.gz
core-b525884edb1f8a80a8fc6cad58c69bdacc5bdb90.tar.bz2
core-b525884edb1f8a80a8fc6cad58c69bdacc5bdb90.zip
liblog: deal with warning messages
- Fix bug in fake_log_devices when it can not allocate memory failing to use the full on-stack buffer as backup. - remove superfluous code. Bug: 27265662 Change-Id: I97b6cca5f4ce8ecad9beb3a08353de596d6a4ad1
Diffstat (limited to 'liblog')
-rw-r--r--liblog/fake_log_device.c6
-rw-r--r--liblog/log_read.c8
2 files changed, 4 insertions, 10 deletions
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 4942c089a..aa88bedf8 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -469,13 +469,13 @@ static void showLog(LogState *state,
if (numLines > MAX_LINES)
numLines = MAX_LINES;
- numVecs = numLines*3; // 3 iovecs per line.
+ numVecs = numLines * 3; // 3 iovecs per line.
if (numVecs > INLINE_VECS) {
vec = (struct iovec*)malloc(sizeof(struct iovec)*numVecs);
if (vec == NULL) {
msg = "LOG: write failed, no memory";
- numVecs = 3;
- numLines = 1;
+ numVecs = INLINE_VECS;
+ numLines = numVecs / 3;
vec = stackVec;
}
}
diff --git a/liblog/log_read.c b/liblog/log_read.c
index 1aff272f7..fc63d2cf9 100644
--- a/liblog/log_read.c
+++ b/liblog/log_read.c
@@ -503,10 +503,7 @@ ssize_t android_logger_get_statistics(struct logger_list *logger_list,
}
if (logger_list->pid) {
- n = snprintf(cp, remaining, " pid=%u", logger_list->pid);
- n = min(n, remaining);
- remaining -= n;
- cp += n;
+ snprintf(cp, remaining, " pid=%u", logger_list->pid);
}
return send_log_msg(NULL, NULL, buf, len);
@@ -657,7 +654,6 @@ static int android_logger_list_read_pstore(struct logger_list *logger_list,
preread_count = 0;
}
- ret = 0;
while(1) {
if (preread_count < sizeof(buf)) {
ret = TEMP_FAILURE_RETRY(read(logger_list->sock,
@@ -834,7 +830,6 @@ int android_logger_list_read(struct logger_list *logger_list,
if (logger_list->pid) {
ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
ret = min(ret, remaining);
- remaining -= ret;
cp += ret;
}
@@ -867,7 +862,6 @@ int android_logger_list_read(struct logger_list *logger_list,
logger_list->sock = sock;
}
- ret = 0;
while(1) {
memset(log_msg, 0, sizeof(*log_msg));