summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-08-13 14:22:56 -0700
committerChih-Hung Hsieh <chh@google.com>2018-08-13 14:24:33 -0700
commit08d470bf08ce94f9e9860a7ba8ce2903502f093a (patch)
treea471de13c7a2fa9f776b1915dfbc0b2f44374bf2 /logd
parent3b984c7efe00d72df699a439e422fe81178b9a58 (diff)
downloadsystem_core-08d470bf08ce94f9e9860a7ba8ce2903502f093a.tar.gz
system_core-08d470bf08ce94f9e9860a7ba8ce2903502f093a.tar.bz2
system_core-08d470bf08ce94f9e9860a7ba8ce2903502f093a.zip
Replace (unsigned) short with (u)int16_t.
Bug: 112478838 Test: build with WITH_TIDY=1 Change-Id: I4b81e6287e72bce2d3cb67cacd6220d064818852
Diffstat (limited to 'logd')
-rw-r--r--logd/LogAudit.cpp10
-rw-r--r--logd/LogBuffer.cpp12
-rw-r--r--logd/LogBuffer.h2
-rw-r--r--logd/LogBufferElement.cpp4
-rw-r--r--logd/LogBufferElement.h9
-rw-r--r--logd/LogBufferInterface.h2
-rw-r--r--logd/LogKlog.cpp3
-rw-r--r--logd/LogListener.cpp2
-rw-r--r--logd/LogStatistics.cpp12
-rw-r--r--logd/LogStatistics.h2
10 files changed, 29 insertions, 29 deletions
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 4ea787791..fc8c96030 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -19,6 +19,7 @@
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
@@ -344,8 +345,7 @@ int LogAudit::logPrint(const char* fmt, ...) {
rc = logbuf->log(
LOG_ID_EVENTS, now, uid, pid, tid, reinterpret_cast<char*>(event),
- (message_len <= USHRT_MAX) ? (unsigned short)message_len
- : USHRT_MAX);
+ (message_len <= UINT16_MAX) ? (uint16_t)message_len : UINT16_MAX);
if (rc >= 0) {
notify |= 1 << LOG_ID_EVENTS;
}
@@ -399,9 +399,9 @@ int LogAudit::logPrint(const char* fmt, ...) {
strncpy(newstr + 1 + str_len + prefix_len + suffix_len,
denial_metadata.c_str(), denial_metadata.length());
- rc = logbuf->log(LOG_ID_MAIN, now, uid, pid, tid, newstr,
- (message_len <= USHRT_MAX) ? (unsigned short)message_len
- : USHRT_MAX);
+ rc = logbuf->log(
+ LOG_ID_MAIN, now, uid, pid, tid, newstr,
+ (message_len <= UINT16_MAX) ? (uint16_t)message_len : UINT16_MAX);
if (rc >= 0) {
notify |= 1 << LOG_ID_MAIN;
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 9b0436367..fd1b8b211 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -199,7 +199,7 @@ static enum match_type identical(LogBufferElement* elem,
}
int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
- pid_t tid, const char* msg, unsigned short len) {
+ pid_t tid, const char* msg, uint16_t len) {
if (log_id >= LOG_ID_MAX) {
return -EINVAL;
}
@@ -240,7 +240,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
LogBufferElement* currentLast = lastLoggedElements[log_id];
if (currentLast) {
LogBufferElement* dropped = droppedElements[log_id];
- unsigned short count = dropped ? dropped->getDropped() : 0;
+ uint16_t count = dropped ? dropped->getDropped() : 0;
//
// State Init
// incoming:
@@ -584,13 +584,13 @@ class LogBufferElementLast {
LogBufferElementMap map;
public:
- bool coalesce(LogBufferElement* element, unsigned short dropped) {
+ bool coalesce(LogBufferElement* element, uint16_t dropped) {
LogBufferElementKey key(element->getUid(), element->getPid(),
element->getTid());
LogBufferElementMap::iterator it = map.find(key.getKey());
if (it != map.end()) {
LogBufferElement* found = it->second;
- unsigned short moreDropped = found->getDropped();
+ uint16_t moreDropped = found->getDropped();
if ((dropped + moreDropped) > USHRT_MAX) {
map.erase(it);
} else {
@@ -847,7 +847,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
mLastSet[id] = true;
}
- unsigned short dropped = element->getDropped();
+ uint16_t dropped = element->getDropped();
// remove any leading drops
if (leading && dropped) {
@@ -927,7 +927,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
kick = true;
- unsigned short len = element->getMsgLen();
+ uint16_t len = element->getMsgLen();
// do not create any leading drops
if (leading) {
diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h
index 094298799..774d4ab0b 100644
--- a/logd/LogBuffer.h
+++ b/logd/LogBuffer.h
@@ -115,7 +115,7 @@ class LogBuffer : public LogBufferInterface {
}
int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
- const char* msg, unsigned short len) override;
+ const char* msg, uint16_t len) override;
// lastTid is an optional context to help detect if the last previous
// valid message was from the same source so we can differentiate chatty
// filter types (identical or expired)
diff --git a/logd/LogBufferElement.cpp b/logd/LogBufferElement.cpp
index 2d627b957..19e6d6822 100644
--- a/logd/LogBufferElement.cpp
+++ b/logd/LogBufferElement.cpp
@@ -35,7 +35,7 @@ atomic_int_fast64_t LogBufferElement::sequence(1);
LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime,
uid_t uid, pid_t pid, pid_t tid,
- const char* msg, unsigned short len)
+ const char* msg, uint16_t len)
: mUid(uid),
mPid(pid),
mTid(tid),
@@ -71,7 +71,7 @@ uint32_t LogBufferElement::getTag() const {
: 0;
}
-unsigned short LogBufferElement::setDropped(unsigned short value) {
+uint16_t LogBufferElement::setDropped(uint16_t value) {
// The tag information is saved in mMsg data, if the tag is non-zero
// save only the information needed to get the tag.
if (getTag() != 0) {
diff --git a/logd/LogBufferElement.h b/logd/LogBufferElement.h
index b168645f1..57b0a95bb 100644
--- a/logd/LogBufferElement.h
+++ b/logd/LogBufferElement.h
@@ -18,6 +18,7 @@
#define _LOGD_LOG_BUFFER_ELEMENT_H__
#include <stdatomic.h>
+#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -56,7 +57,7 @@ class __attribute__((packed)) LogBufferElement {
public:
LogBufferElement(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
- pid_t tid, const char* msg, unsigned short len);
+ pid_t tid, const char* msg, uint16_t len);
LogBufferElement(const LogBufferElement& elem);
~LogBufferElement();
@@ -77,11 +78,11 @@ class __attribute__((packed)) LogBufferElement {
return mTid;
}
uint32_t getTag() const;
- unsigned short getDropped(void) const {
+ uint16_t getDropped(void) const {
return mDropped ? mDroppedCount : 0;
}
- unsigned short setDropped(unsigned short value);
- unsigned short getMsgLen() const {
+ uint16_t setDropped(uint16_t value);
+ uint16_t getMsgLen() const {
return mDropped ? 0 : mMsgLen;
}
const char* getMsg() const {
diff --git a/logd/LogBufferInterface.h b/logd/LogBufferInterface.h
index ff73a227c..f31e24457 100644
--- a/logd/LogBufferInterface.h
+++ b/logd/LogBufferInterface.h
@@ -31,7 +31,7 @@ class LogBufferInterface {
// Handles a log entry when available in LogListener.
// Returns the size of the handled log message.
virtual int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
- pid_t tid, const char* msg, unsigned short len) = 0;
+ pid_t tid, const char* msg, uint16_t len) = 0;
virtual uid_t pidToUid(pid_t pid);
virtual pid_t tidToPid(pid_t tid);
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
index ab980ac5d..e4393a3c1 100644
--- a/logd/LogKlog.cpp
+++ b/logd/LogKlog.cpp
@@ -821,8 +821,7 @@ int LogKlog::log(const char* buf, ssize_t len) {
}
// Log message
- int rc = logbuf->log(LOG_ID_KERNEL, now, uid, pid, tid, newstr,
- (unsigned short)n);
+ int rc = logbuf->log(LOG_ID_KERNEL, now, uid, pid, tid, newstr, (uint16_t)n);
// notify readers
if (rc > 0) {
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index e568ddcf4..2f227788c 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -136,7 +136,7 @@ bool LogListener::onDataAvailable(SocketClient* cli) {
if (logbuf != nullptr) {
int res = logbuf->log(
logId, header->realtime, cred->uid, cred->pid, header->tid, msg,
- ((size_t)n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX);
+ ((size_t)n <= UINT16_MAX) ? (uint16_t)n : UINT16_MAX);
if (res > 0 && reader != nullptr) {
reader->notifyNewLog(static_cast<log_mask_t>(1 << logId));
}
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index cefacf775..116e08eba 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -83,7 +83,7 @@ void LogStatistics::addTotal(LogBufferElement* element) {
if (element->getDropped()) return;
log_id_t log_id = element->getLogId();
- unsigned short size = element->getMsgLen();
+ uint16_t size = element->getMsgLen();
mSizesTotal[log_id] += size;
SizesTotal += size;
++mElementsTotal[log_id];
@@ -91,7 +91,7 @@ void LogStatistics::addTotal(LogBufferElement* element) {
void LogStatistics::add(LogBufferElement* element) {
log_id_t log_id = element->getLogId();
- unsigned short size = element->getMsgLen();
+ uint16_t size = element->getMsgLen();
mSizes[log_id] += size;
++mElements[log_id];
@@ -161,7 +161,7 @@ void LogStatistics::add(LogBufferElement* element) {
void LogStatistics::subtract(LogBufferElement* element) {
log_id_t log_id = element->getLogId();
- unsigned short size = element->getMsgLen();
+ uint16_t size = element->getMsgLen();
mSizes[log_id] -= size;
--mElements[log_id];
if (element->getDropped()) {
@@ -206,7 +206,7 @@ void LogStatistics::subtract(LogBufferElement* element) {
// entry->setDropped(1) must follow this call, caller should do this explicitly.
void LogStatistics::drop(LogBufferElement* element) {
log_id_t log_id = element->getLogId();
- unsigned short size = element->getMsgLen();
+ uint16_t size = element->getMsgLen();
mSizes[log_id] -= size;
++mDroppedElements[log_id];
@@ -613,13 +613,13 @@ static std::string formatMsec(uint64_t val) {
std::string LogStatistics::format(uid_t uid, pid_t pid,
unsigned int logMask) const {
- static const unsigned short spaces_total = 19;
+ static const uint16_t spaces_total = 19;
// Report on total logging, current and for all time
std::string output = "size/num";
size_t oldLength;
- short spaces = 1;
+ int16_t spaces = 1;
log_id_for_each(id) {
if (!(logMask & (1 << id))) continue;
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index ac3cf9af2..d6b8ab385 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -520,7 +520,7 @@ struct TagNameKey {
return;
}
++msg;
- unsigned short len = element->getMsgLen();
+ uint16_t len = element->getMsgLen();
len = (len <= 1) ? 0 : strnlen(msg, len - 1);
if (!len) {
name = std::string_view("<NULL>", strlen("<NULL>"));