Replace (unsigned) short with (u)int16_t.
Bug: 112478838 Test: build with WITH_TIDY=1 Change-Id: I4b81e6287e72bce2d3cb67cacd6220d064818852
This commit is contained in:
parent
3b984c7efe
commit
08d470bf08
10 changed files with 29 additions and 29 deletions
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>"));
|
||||
|
|
Loading…
Reference in a new issue