Loading logd/LogAudit.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; } Loading Loading @@ -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; Loading logd/LogBuffer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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: Loading Loading @@ -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 { Loading Loading @@ -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) { Loading Loading @@ -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) { Loading logd/LogBuffer.h +1 −1 Original line number Diff line number Diff line Loading @@ -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) Loading logd/LogBufferElement.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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) { Loading logd/LogBufferElement.h +5 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _LOGD_LOG_BUFFER_ELEMENT_H__ #include <stdatomic.h> #include <stdint.h> #include <stdlib.h> #include <sys/types.h> Loading Loading @@ -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(); Loading @@ -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 { Loading Loading
logd/LogAudit.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; } Loading Loading @@ -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; Loading
logd/LogBuffer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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: Loading Loading @@ -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 { Loading Loading @@ -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) { Loading Loading @@ -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) { Loading
logd/LogBuffer.h +1 −1 Original line number Diff line number Diff line Loading @@ -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) Loading
logd/LogBufferElement.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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) { Loading
logd/LogBufferElement.h +5 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _LOGD_LOG_BUFFER_ELEMENT_H__ #include <stdatomic.h> #include <stdint.h> #include <stdlib.h> #include <sys/types.h> Loading Loading @@ -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(); Loading @@ -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 { Loading