Merge "logd: switch to using arraysize() from libbase macros"
This commit is contained in:
commit
fc08963f85
2 changed files with 8 additions and 6 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
|
#include <android-base/macros.h>
|
||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
#include <private/android_logger.h>
|
#include <private/android_logger.h>
|
||||||
|
|
||||||
|
|
@ -143,7 +144,7 @@ int LogAudit::logPrint(const char *fmt, ...) {
|
||||||
iov[2].iov_len = strlen(newline);
|
iov[2].iov_len = strlen(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
writev(fdDmesg, iov, sizeof(iov) / sizeof(iov[0]));
|
writev(fdDmesg, iov, arraysize(iov));
|
||||||
free(last_str);
|
free(last_str);
|
||||||
last_str = NULL;
|
last_str = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +166,7 @@ int LogAudit::logPrint(const char *fmt, ...) {
|
||||||
iov[2].iov_base = const_cast<char *>(newline);
|
iov[2].iov_base = const_cast<char *>(newline);
|
||||||
iov[2].iov_len = strlen(newline);
|
iov[2].iov_len = strlen(newline);
|
||||||
|
|
||||||
writev(fdDmesg, iov, sizeof(iov) / sizeof(iov[0]));
|
writev(fdDmesg, iov, arraysize(iov));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <android-base/macros.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
@ -351,7 +352,7 @@ TEST(logd, both) {
|
||||||
"/dev/log/system", "/dev/log_system",
|
"/dev/log/system", "/dev/log_system",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < (sizeof(loggers) / sizeof(loggers[0])); ++i) {
|
for (unsigned int i = 0; i < arraysize(loggers); ++i) {
|
||||||
fd = open(loggers[i], O_RDONLY);
|
fd = open(loggers[i], O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -434,12 +435,12 @@ TEST(logd, benchmark) {
|
||||||
static const unsigned int log_latency = 4;
|
static const unsigned int log_latency = 4;
|
||||||
static const unsigned int log_delay = 5;
|
static const unsigned int log_delay = 5;
|
||||||
|
|
||||||
unsigned long ns[sizeof(benchmarks) / sizeof(benchmarks[0])];
|
unsigned long ns[arraysize(benchmarks)];
|
||||||
|
|
||||||
memset(ns, 0, sizeof(ns));
|
memset(ns, 0, sizeof(ns));
|
||||||
|
|
||||||
while (fgets(buffer, sizeof(buffer), fp)) {
|
while (fgets(buffer, sizeof(buffer), fp)) {
|
||||||
for (unsigned i = 0; i < sizeof(ns) / sizeof(ns[0]); ++i) {
|
for (unsigned i = 0; i < arraysize(ns); ++i) {
|
||||||
char *cp = strstr(buffer, benchmarks[i]);
|
char *cp = strstr(buffer, benchmarks[i]);
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -470,7 +471,7 @@ TEST(logd, benchmark) {
|
||||||
|
|
||||||
EXPECT_GE(20000000UL, ns[log_delay]); // 10500289 user
|
EXPECT_GE(20000000UL, ns[log_delay]); // 10500289 user
|
||||||
|
|
||||||
for (unsigned i = 0; i < sizeof(ns) / sizeof(ns[0]); ++i) {
|
for (unsigned i = 0; i < arraysize(ns); ++i) {
|
||||||
EXPECT_NE(0UL, ns[i]);
|
EXPECT_NE(0UL, ns[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue