Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb2314e5 authored by Mark Salyzyn's avatar Mark Salyzyn Committed by android-build-merger
Browse files

Merge "logd: switch to using arraysize() from libbase macros"

am: fc08963f

Change-Id: If17fd9389ec65f379fa42096e835be2ed667f703
parents 360cd766 fc08963f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <sys/uio.h>
#include <syslog.h>

#include <android-base/macros.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

@@ -143,7 +144,7 @@ int LogAudit::logPrint(const char *fmt, ...) {
                    iov[2].iov_len = strlen(newline);
                }

                writev(fdDmesg, iov, sizeof(iov) / sizeof(iov[0]));
                writev(fdDmesg, iov, arraysize(iov));
                free(last_str);
                last_str = NULL;
            }
@@ -165,7 +166,7 @@ int LogAudit::logPrint(const char *fmt, ...) {
            iov[2].iov_base = const_cast<char *>(newline);
            iov[2].iov_len = strlen(newline);

            writev(fdDmesg, iov, sizeof(iov) / sizeof(iov[0]));
            writev(fdDmesg, iov, arraysize(iov));
        }
    }

+5 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

#include <string>

#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <cutils/sockets.h>
#include <gtest/gtest.h>
@@ -351,7 +352,7 @@ TEST(logd, both) {
        "/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);
        if (fd < 0) {
            continue;
@@ -434,12 +435,12 @@ TEST(logd, benchmark) {
    static const unsigned int log_latency = 4;
    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));

    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]);
            if (!cp) {
                continue;
@@ -470,7 +471,7 @@ TEST(logd, benchmark) {

    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]);
    }