summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2014-09-12 16:02:28 -0700
committerMark Salyzyn <salyzyn@google.com>2014-09-12 23:37:42 +0000
commit634118e261d2a3c6f67212f43a4ec3f075d705b6 (patch)
treeb28d7d60199cd2b20272a30c51fddec49d0bc5de /logd
parentf41ee3d5a1f236b0770d1ebd7068606aea7288bd (diff)
downloadsystem_core-634118e261d2a3c6f67212f43a4ec3f075d705b6.tar.gz
system_core-634118e261d2a3c6f67212f43a4ec3f075d705b6.tar.bz2
system_core-634118e261d2a3c6f67212f43a4ec3f075d705b6.zip
logd: fix format-extra-args warning.
Bug: 17409250 Change-Id: Id50ebb57754b12d69ed605d0e2901b8e05c607c6
Diffstat (limited to 'logd')
-rw-r--r--logd/LogStatistics.cpp22
-rw-r--r--logd/LogWhiteBlackList.cpp13
-rw-r--r--logd/tests/logd_test.cpp6
3 files changed, 28 insertions, 13 deletions
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index a2f27c641..82f91655b 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -671,8 +671,11 @@ void LogStatistics::format(char **buf,
size_t sizesTotal = p->sizesTotal();
android::String8 sz("");
- sz.appendFormat((sizes != sizesTotal) ? "%zu/%zu" : "%zu",
- sizes, sizesTotal);
+ if (sizes == sizesTotal) {
+ sz.appendFormat("%zu", sizes);
+ } else {
+ sz.appendFormat("%zu/%zu", sizes, sizesTotal);
+ }
android::String8 pd("");
pd.appendFormat("%u%c", pid, p->pidGone() ? '?' : ' ');
@@ -783,12 +786,15 @@ void LogStatistics::format(char **buf,
PidStatistics *pp = *pt;
pid_t p = pp->getPid();
- intermediate = string.format(oneline
- ? ((p == PidStatistics::gone)
- ? "%d/?"
- : "%d/%d%c")
- : "%d",
- u, p, pp->pidGone() ? '?' : '\0');
+ if (!oneline) {
+ intermediate = string.format("%d", u);
+ } else if (p == PidStatistics::gone) {
+ intermediate = string.format("%d/?", u);
+ } else if (pp->pidGone()) {
+ intermediate = string.format("%d/%d?", u, p);
+ } else {
+ intermediate = string.format("%d/%d", u, p);
+ }
string.appendFormat(first ? "\n%-12s" : "%-12s",
intermediate.string());
intermediate.clear();
diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp
index e87b6047c..9728db17b 100644
--- a/logd/LogWhiteBlackList.cpp
+++ b/logd/LogWhiteBlackList.cpp
@@ -39,10 +39,15 @@ int Prune::cmp(uid_t uid, pid_t pid) const {
void Prune::format(char **strp) {
if (mUid != uid_all) {
- asprintf(strp, (mPid != pid_all) ? "%u/%u" : "%u", mUid, mPid);
- } else {
- // NB: mPid == pid_all can not happen if mUid == uid_all
- asprintf(strp, (mPid != pid_all) ? "/%u" : "/", mPid);
+ if (mPid != pid_all) {
+ asprintf(strp, "%u/%u", mUid, mPid);
+ } else {
+ asprintf(strp, "%u", mUid);
+ }
+ } else if (mPid != pid_all) {
+ asprintf(strp, "/%u", mPid);
+ } else { // NB: mPid == pid_all can not happen if mUid == uid_all
+ asprintf(strp, "/");
}
}
diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp
index 4bea4bee6..96877a940 100644
--- a/logd/tests/logd_test.cpp
+++ b/logd/tests/logd_test.cpp
@@ -417,7 +417,11 @@ static void dump_log_msg(const char *prefix,
if (((p - cp) > 3) && !*p && ((unsigned int)(p - cp) < len)) {
fprintf(stderr, "\"");
while (*cp) {
- fprintf(stderr, (*cp != '\n') ? "%c" : "\\n", *cp);
+ if (*cp != '\n') {
+ fprintf(stderr, "%c", *cp);
+ } else {
+ fprintf(stderr, "\\n");
+ }
++cp;
--len;
}