summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--logd/CommandListener.cpp79
-rw-r--r--logd/FlushCommand.cpp16
-rw-r--r--logd/LogAudit.cpp12
-rw-r--r--logd/LogBuffer.cpp3
-rw-r--r--logd/LogBufferElement.cpp16
-rw-r--r--logd/LogCommand.cpp3
-rw-r--r--logd/LogKlog.cpp20
-rw-r--r--logd/LogListener.cpp10
-rw-r--r--logd/LogReader.cpp24
-rw-r--r--logd/LogStatistics.cpp3
-rw-r--r--logd/LogTimes.cpp35
-rw-r--r--logd/LogWhiteBlackList.cpp9
12 files changed, 111 insertions, 119 deletions
diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp
index bdfed3b2b..5489cc945 100644
--- a/logd/CommandListener.cpp
+++ b/logd/CommandListener.cpp
@@ -33,9 +33,9 @@
33#include "LogCommand.h" 33#include "LogCommand.h"
34 34
35CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, 35CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/,
36 LogListener * /*swl*/) 36 LogListener * /*swl*/) :
37 : FrameworkListener(getLogSocket()) 37 FrameworkListener(getLogSocket()),
38 , mBuf(*buf) { 38 mBuf(*buf) {
39 // registerCmd(new ShutdownCmd(buf, writer, swl)); 39 // registerCmd(new ShutdownCmd(buf, writer, swl));
40 registerCmd(new ClearCmd(buf)); 40 registerCmd(new ClearCmd(buf));
41 registerCmd(new GetBufSizeCmd(buf)); 41 registerCmd(new GetBufSizeCmd(buf));
@@ -48,12 +48,12 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/,
48} 48}
49 49
50CommandListener::ShutdownCmd::ShutdownCmd(LogBuffer *buf, LogReader *reader, 50CommandListener::ShutdownCmd::ShutdownCmd(LogBuffer *buf, LogReader *reader,
51 LogListener *swl) 51 LogListener *swl) :
52 : LogCommand("shutdown") 52 LogCommand("shutdown"),
53 , mBuf(*buf) 53 mBuf(*buf),
54 , mReader(*reader) 54 mReader(*reader),
55 , mSwl(*swl) 55 mSwl(*swl) {
56{ } 56}
57 57
58int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/, 58int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/,
59 int /*argc*/, 59 int /*argc*/,
@@ -63,10 +63,10 @@ int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/,
63 exit(0); 63 exit(0);
64} 64}
65 65
66CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) 66CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) :
67 : LogCommand("clear") 67 LogCommand("clear"),
68 , mBuf(*buf) 68 mBuf(*buf) {
69{ } 69}
70 70
71static void setname() { 71static void setname() {
72 static bool name_set; 72 static bool name_set;
@@ -100,10 +100,10 @@ int CommandListener::ClearCmd::runCommand(SocketClient *cli,
100 return 0; 100 return 0;
101} 101}
102 102
103CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) 103CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) :
104 : LogCommand("getLogSize") 104 LogCommand("getLogSize"),
105 , mBuf(*buf) 105 mBuf(*buf) {
106{ } 106}
107 107
108int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, 108int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli,
109 int argc, char **argv) { 109 int argc, char **argv) {
@@ -126,10 +126,10 @@ int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli,
126 return 0; 126 return 0;
127} 127}
128 128
129CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) 129CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) :
130 : LogCommand("setLogSize") 130 LogCommand("setLogSize"),
131 , mBuf(*buf) 131 mBuf(*buf) {
132{ } 132}
133 133
134int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, 134int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli,
135 int argc, char **argv) { 135 int argc, char **argv) {
@@ -160,10 +160,10 @@ int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli,
160 return 0; 160 return 0;
161} 161}
162 162
163CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) 163CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) :
164 : LogCommand("getLogSizeUsed") 164 LogCommand("getLogSizeUsed"),
165 , mBuf(*buf) 165 mBuf(*buf) {
166{ } 166}
167 167
168int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli, 168int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli,
169 int argc, char **argv) { 169 int argc, char **argv) {
@@ -186,10 +186,10 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli,
186 return 0; 186 return 0;
187} 187}
188 188
189CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) 189CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) :
190 : LogCommand("getStatistics") 190 LogCommand("getStatistics"),
191 , mBuf(*buf) 191 mBuf(*buf) {
192{ } 192}
193 193
194static void package_string(char **strp) { 194static void package_string(char **strp) {
195 const char *a = *strp; 195 const char *a = *strp;
@@ -243,10 +243,10 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli,
243 return 0; 243 return 0;
244} 244}
245 245
246CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) 246CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) :
247 : LogCommand("getPruneList") 247 LogCommand("getPruneList"),
248 , mBuf(*buf) 248 mBuf(*buf) {
249{ } 249}
250 250
251int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, 251int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli,
252 int /*argc*/, char ** /*argv*/) { 252 int /*argc*/, char ** /*argv*/) {
@@ -263,10 +263,10 @@ int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli,
263 return 0; 263 return 0;
264} 264}
265 265
266CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) 266CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) :
267 : LogCommand("setPruneList") 267 LogCommand("setPruneList"),
268 , mBuf(*buf) 268 mBuf(*buf) {
269{ } 269}
270 270
271int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, 271int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli,
272 int argc, char **argv) { 272 int argc, char **argv) {
@@ -301,9 +301,8 @@ int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli,
301 return 0; 301 return 0;
302} 302}
303 303
304CommandListener::ReinitCmd::ReinitCmd() 304CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") {
305 : LogCommand("reinit") 305}
306{ }
307 306
308int CommandListener::ReinitCmd::runCommand(SocketClient *cli, 307int CommandListener::ReinitCmd::runCommand(SocketClient *cli,
309 int /*argc*/, char ** /*argv*/) { 308 int /*argc*/, char ** /*argv*/) {
diff --git a/logd/FlushCommand.cpp b/logd/FlushCommand.cpp
index 26a18610d..d58492586 100644
--- a/logd/FlushCommand.cpp
+++ b/logd/FlushCommand.cpp
@@ -27,14 +27,14 @@ FlushCommand::FlushCommand(LogReader &reader,
27 unsigned long tail, 27 unsigned long tail,
28 unsigned int logMask, 28 unsigned int logMask,
29 pid_t pid, 29 pid_t pid,
30 uint64_t start) 30 uint64_t start) :
31 : mReader(reader) 31 mReader(reader),
32 , mNonBlock(nonBlock) 32 mNonBlock(nonBlock),
33 , mTail(tail) 33 mTail(tail),
34 , mLogMask(logMask) 34 mLogMask(logMask),
35 , mPid(pid) 35 mPid(pid),
36 , mStart(start) 36 mStart(start) {
37{ } 37}
38 38
39// runSocketCommand is called once for every open client on the 39// runSocketCommand is called once for every open client on the
40// log reader socket. Here we manage and associated the reader 40// log reader socket. Here we manage and associated the reader
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 09cdb1894..4ec2e59f2 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -37,12 +37,12 @@
37 '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, \ 37 '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, \
38 '>' 38 '>'
39 39
40LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmesg) 40LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmesg) :
41 : SocketListener(getLogSocket(), false) 41 SocketListener(getLogSocket(), false),
42 , logbuf(buf) 42 logbuf(buf),
43 , reader(reader) 43 reader(reader),
44 , fdDmesg(fdDmesg) 44 fdDmesg(fdDmesg),
45 , initialized(false) { 45 initialized(false) {
46 static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO), 46 static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO),
47 'l', 'o', 'g', 'd', '.', 'a', 'u', 'd', 'i', 't', 'd', ':', 47 'l', 'o', 'g', 'd', '.', 'a', 'u', 'd', 'i', 't', 'd', ':',
48 ' ', 's', 't', 'a', 'r', 't', '\n' }; 48 ' ', 's', 't', 'a', 'r', 't', '\n' };
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index b6b612468..c33dca68d 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -126,8 +126,7 @@ void LogBuffer::init() {
126 } 126 }
127} 127}
128 128
129LogBuffer::LogBuffer(LastLogTimes *times) 129LogBuffer::LogBuffer(LastLogTimes *times) : mTimes(*times) {
130 : mTimes(*times) {
131 pthread_mutex_init(&mLogElementsLock, NULL); 130 pthread_mutex_init(&mLogElementsLock, NULL);
132 131
133 init(); 132 init();
diff --git a/logd/LogBufferElement.cpp b/logd/LogBufferElement.cpp
index 164faa9f8..f98d5cdc1 100644
--- a/logd/LogBufferElement.cpp
+++ b/logd/LogBufferElement.cpp
@@ -34,14 +34,14 @@ atomic_int_fast64_t LogBufferElement::sequence;
34 34
35LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime, 35LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime,
36 uid_t uid, pid_t pid, pid_t tid, 36 uid_t uid, pid_t pid, pid_t tid,
37 const char *msg, unsigned short len) 37 const char *msg, unsigned short len) :
38 : mLogId(log_id) 38 mLogId(log_id),
39 , mUid(uid) 39 mUid(uid),
40 , mPid(pid) 40 mPid(pid),
41 , mTid(tid) 41 mTid(tid),
42 , mMsgLen(len) 42 mMsgLen(len),
43 , mSequence(sequence.fetch_add(1, memory_order_relaxed)) 43 mSequence(sequence.fetch_add(1, memory_order_relaxed)),
44 , mRealTime(realtime) { 44 mRealTime(realtime) {
45 mMsg = new char[len]; 45 mMsg = new char[len];
46 memcpy(mMsg, msg, len); 46 memcpy(mMsg, msg, len);
47} 47}
diff --git a/logd/LogCommand.cpp b/logd/LogCommand.cpp
index b78c0e0a7..06d865cd5 100644
--- a/logd/LogCommand.cpp
+++ b/logd/LogCommand.cpp
@@ -23,8 +23,7 @@
23 23
24#include "LogCommand.h" 24#include "LogCommand.h"
25 25
26LogCommand::LogCommand(const char *cmd) 26LogCommand::LogCommand(const char *cmd) : FrameworkCommand(cmd) {
27 : FrameworkCommand(cmd) {
28} 27}
29 28
30// gets a list of supplementary group IDs associated with 29// gets a list of supplementary group IDs associated with
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
index 35fe3a5e9..8df0d0a84 100644
--- a/logd/LogKlog.cpp
+++ b/logd/LogKlog.cpp
@@ -38,16 +38,16 @@ static const char priority_message[] = { KMSG_PRIORITY(LOG_INFO), '\0' };
38 38
39log_time LogKlog::correction = log_time(CLOCK_REALTIME) - log_time(CLOCK_MONOTONIC); 39log_time LogKlog::correction = log_time(CLOCK_REALTIME) - log_time(CLOCK_MONOTONIC);
40 40
41LogKlog::LogKlog(LogBuffer *buf, LogReader *reader, int fdWrite, int fdRead, bool auditd) 41LogKlog::LogKlog(LogBuffer *buf, LogReader *reader, int fdWrite, int fdRead, bool auditd) :
42 : SocketListener(fdRead, false) 42 SocketListener(fdRead, false),
43 , logbuf(buf) 43 logbuf(buf),
44 , reader(reader) 44 reader(reader),
45 , signature(CLOCK_MONOTONIC) 45 signature(CLOCK_MONOTONIC),
46 , fdWrite(fdWrite) 46 fdWrite(fdWrite),
47 , fdRead(fdRead) 47 fdRead(fdRead),
48 , initialized(false) 48 initialized(false),
49 , enableLogging(true) 49 enableLogging(true),
50 , auditd(auditd) { 50 auditd(auditd) {
51 static const char klogd_message[] = "%slogd.klogd: %" PRIu64 "\n"; 51 static const char klogd_message[] = "%slogd.klogd: %" PRIu64 "\n";
52 char buffer[sizeof(priority_message) + sizeof(klogd_message) + 20 - 4]; 52 char buffer[sizeof(priority_message) + sizeof(klogd_message) + 20 - 4];
53 snprintf(buffer, sizeof(buffer), klogd_message, priority_message, 53 snprintf(buffer, sizeof(buffer), klogd_message, priority_message,
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index 17b6e6f9a..b29f5ab92 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -28,11 +28,11 @@
28 28
29#include "LogListener.h" 29#include "LogListener.h"
30 30
31LogListener::LogListener(LogBuffer *buf, LogReader *reader) 31LogListener::LogListener(LogBuffer *buf, LogReader *reader) :
32 : SocketListener(getLogSocket(), false) 32 SocketListener(getLogSocket(), false),
33 , logbuf(buf) 33 logbuf(buf),
34 , reader(reader) 34 reader(reader) {
35{ } 35}
36 36
37bool LogListener::onDataAvailable(SocketClient *cli) { 37bool LogListener::onDataAvailable(SocketClient *cli) {
38 static bool name_set; 38 static bool name_set;
diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp
index 745e8477e..c7deec0d6 100644
--- a/logd/LogReader.cpp
+++ b/logd/LogReader.cpp
@@ -24,10 +24,10 @@
24#include "LogReader.h" 24#include "LogReader.h"
25#include "FlushCommand.h" 25#include "FlushCommand.h"
26 26
27LogReader::LogReader(LogBuffer *logbuf) 27LogReader::LogReader(LogBuffer *logbuf) :
28 : SocketListener(getLogSocket(), true) 28 SocketListener(getLogSocket(), true),
29 , mLogbuf(*logbuf) 29 mLogbuf(*logbuf) {
30{ } 30}
31 31
32// When we are notified a new log entry is available, inform 32// When we are notified a new log entry is available, inform
33// all of our listening sockets. 33// all of our listening sockets.
@@ -116,14 +116,14 @@ bool LogReader::onDataAvailable(SocketClient *cli) {
116 uint64_t last; 116 uint64_t last;
117 117
118 public: 118 public:
119 LogFindStart(unsigned logMask, pid_t pid, log_time &start, uint64_t &sequence) 119 LogFindStart(unsigned logMask, pid_t pid, log_time &start, uint64_t &sequence) :
120 : mPid(pid) 120 mPid(pid),
121 , mLogMask(logMask) 121 mLogMask(logMask),
122 , startTimeSet(false) 122 startTimeSet(false),
123 , start(start) 123 start(start),
124 , sequence(sequence) 124 sequence(sequence),
125 , last(sequence) 125 last(sequence) {
126 { } 126 }
127 127
128 static int callback(const LogBufferElement *element, void *obj) { 128 static int callback(const LogBufferElement *element, void *obj) {
129 LogFindStart *me = reinterpret_cast<LogFindStart *>(obj); 129 LogFindStart *me = reinterpret_cast<LogFindStart *>(obj);
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index 9756b2d3e..675b69274 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -26,8 +26,7 @@
26 26
27#include "LogStatistics.h" 27#include "LogStatistics.h"
28 28
29LogStatistics::LogStatistics() 29LogStatistics::LogStatistics() : enable(false) {
30 : enable(false) {
31 log_id_for_each(id) { 30 log_id_for_each(id) {
32 mSizes[id] = 0; 31 mSizes[id] = 0;
33 mElements[id] = 0; 32 mElements[id] = 0;
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index 1b60b7ead..ec67c07e8 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -26,24 +26,23 @@ pthread_mutex_t LogTimeEntry::timesLock = PTHREAD_MUTEX_INITIALIZER;
26LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client, 26LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client,
27 bool nonBlock, unsigned long tail, 27 bool nonBlock, unsigned long tail,
28 unsigned int logMask, pid_t pid, 28 unsigned int logMask, pid_t pid,
29 uint64_t start) 29 uint64_t start) :
30 : mRefCount(1) 30 mRefCount(1),
31 , mRelease(false) 31 mRelease(false),
32 , mError(false) 32 mError(false),
33 , threadRunning(false) 33 threadRunning(false),
34 , mReader(reader) 34 mReader(reader),
35 , mLogMask(logMask) 35 mLogMask(logMask),
36 , mPid(pid) 36 mPid(pid),
37 , mCount(0) 37 mCount(0),
38 , mTail(tail) 38 mTail(tail),
39 , mIndex(0) 39 mIndex(0),
40 , mClient(client) 40 mClient(client),
41 , mStart(start) 41 mStart(start),
42 , mNonBlock(nonBlock) 42 mNonBlock(nonBlock),
43 , mEnd(LogBufferElement::getCurrentSequence()) 43 mEnd(LogBufferElement::getCurrentSequence()) {
44{ 44 pthread_cond_init(&threadTriggeredCondition, NULL);
45 pthread_cond_init(&threadTriggeredCondition, NULL); 45 cleanSkip_Locked();
46 cleanSkip_Locked();
47} 46}
48 47
49void LogTimeEntry::startReader_Locked(void) { 48void LogTimeEntry::startReader_Locked(void) {
diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp
index bee940d99..277b3caf4 100644
--- a/logd/LogWhiteBlackList.cpp
+++ b/logd/LogWhiteBlackList.cpp
@@ -22,10 +22,8 @@
22 22
23// White and Black list 23// White and Black list
24 24
25Prune::Prune(uid_t uid, pid_t pid) 25Prune::Prune(uid_t uid, pid_t pid) : mUid(uid), mPid(pid) {
26 : mUid(uid) 26}
27 , mPid(pid)
28{ }
29 27
30int Prune::cmp(uid_t uid, pid_t pid) const { 28int Prune::cmp(uid_t uid, pid_t pid) const {
31 if ((mUid == uid_all) || (mUid == uid)) { 29 if ((mUid == uid_all) || (mUid == uid)) {
@@ -51,8 +49,7 @@ void Prune::format(char **strp) {
51 } 49 }
52} 50}
53 51
54PruneList::PruneList() 52PruneList::PruneList() : mWorstUidEnabled(true) {
55 : mWorstUidEnabled(true) {
56 mNaughty.clear(); 53 mNaughty.clear();
57 mNice.clear(); 54 mNice.clear();
58} 55}