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

Commit 6d5a2fc4 authored by Muhammad Qureshi's avatar Muhammad Qureshi Committed by Ruchir Rastogi
Browse files

Make stats_event write function parameters const

Bug: 143968790
Test: bit statsd_test:*
Change-Id: I413accb10cf3de4c5c49eb06a472168b1171039b
Merged-In: I2660cad5400a0e819c60b9caa706bb66ca2eef4f
parent 962cc23b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -95,14 +95,14 @@ void stats_event_write_int64(struct stats_event* event, int64_t value);
void stats_event_write_float(struct stats_event* event, float value);
void stats_event_write_bool(struct stats_event* event, bool value);

void stats_event_write_byte_array(struct stats_event* event, uint8_t* buf, size_t numBytes);
void stats_event_write_byte_array(struct stats_event* event, const uint8_t* buf, size_t numBytes);

// Buf must be null-terminated.
void stats_event_write_string8(struct stats_event* event, const char* buf);

// Tags must be null-terminated.
void stats_event_write_attribution_chain(struct stats_event* event, uint32_t* uids,
                                         const char** tags, uint8_t numNodes);
void stats_event_write_attribution_chain(struct stats_event* event, const uint32_t* uids,
                                         const char* const* tags, uint8_t numNodes);

/* key_value_pair struct can be constructed as follows:
 *    struct key_value_pair pair = {.key = key, .valueType = STRING_TYPE,
+4 −4
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ static void append_float(struct stats_event* event, float value) {
    }
}

static void append_byte_array(struct stats_event* event, uint8_t* buf, size_t size) {
static void append_byte_array(struct stats_event* event, const uint8_t* buf, size_t size) {
    if (!overflows(event, size)) {
        memcpy(&event->buf[event->size], buf, size);
        event->size += size;
@@ -185,7 +185,7 @@ void stats_event_write_bool(struct stats_event* event, bool value) {
    append_bool(event, value);
}

void stats_event_write_byte_array(struct stats_event* event, uint8_t* buf, size_t numBytes) {
void stats_event_write_byte_array(struct stats_event* event, const uint8_t* buf, size_t numBytes) {
    if (event->errors) return;

    start_field(event, BYTE_ARRAY_TYPE);
@@ -202,8 +202,8 @@ void stats_event_write_string8(struct stats_event* event, const char* buf) {
}

// Tags are assumed to be encoded using UTF8
void stats_event_write_attribution_chain(struct stats_event* event, uint32_t* uids,
                                         const char** tags, uint8_t numNodes) {
void stats_event_write_attribution_chain(struct stats_event* event, const uint32_t* uids,
                                         const char* const* tags, uint8_t numNodes) {
    if (numNodes > MAX_BYTE_VALUE) event->errors |= ERROR_ATTRIBUTION_CHAIN_TOO_LONG;
    if (event->errors) return;