summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-10 18:58:34 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-10 18:58:34 +0000
commit0d70e8d5946a15cf167728fd17e68da6b5ea486d (patch)
treefce96ff1171c912a394d8e4d8e5dd14bcf070382
parent1e318a372288b2fc934fbb12612092188c51581d (diff)
parent15222f7a68c60d3f6771b68500e8af24a9006a11 (diff)
downloadapf-aml_tz5_341510010.tar.gz
Snap for 11296156 from 15222f7a68c60d3f6771b68500e8af24a9006a11 to mainline-tzdata5-releaseaml_tz5_341510070aml_tz5_341510050aml_tz5_341510010aml_tz5_341510010
Change-Id: I1ba4538c4c151bf32dd42c3455aba3e32ceb1561
-rw-r--r--apf_interpreter.h6
-rw-r--r--v5/apf_interpreter.c9
-rw-r--r--v5/apf_interpreter.h6
3 files changed, 12 insertions, 9 deletions
diff --git a/apf_interpreter.h b/apf_interpreter.h
index 368ae04..1c8e7c9 100644
--- a/apf_interpreter.h
+++ b/apf_interpreter.h
@@ -37,9 +37,9 @@ extern "C" {
* begins at program + program_len and ends at program + ram_len - 1,
* as described in the following diagram:
*
- *     program         program + program_len    program + ram_len
- *        |    text section    | data section    |
- *    +--------------------+------------------------+
+ * program program + program_len program + ram_len
+ * | text section | data section |
+ * +--------------------+------------------------+
*
* @param program the program bytecode, followed by the writable data region.
* @param program_len the length in bytes of the read-only portion of the APF
diff --git a/v5/apf_interpreter.c b/v5/apf_interpreter.c
index 9284a45..6679c72 100644
--- a/v5/apf_interpreter.c
+++ b/v5/apf_interpreter.c
@@ -112,8 +112,11 @@ int apf_run(void* ctx, uint8_t* const program, const uint32_t program_len,
// Decode the imm length.
#define DECODE_IMM(value, length) \
- for (uint32_t i = 0; i < (length) && pc < program_len; i++) \
- value = (value << 8) | program[pc++]
+ do { \
+ uint32_t i; \
+ for (i = 0; i < (length) && pc < program_len; i++) \
+ value = (value << 8) | program[pc++]; \
+ } while (0)
do {
APF_TRACE_HOOK(pc, registers, program, program_len, packet, packet_len, memory, ram_len);
@@ -154,7 +157,7 @@ int apf_run(void* ctx, uint8_t* const program, const uint32_t program_len,
offs += registers[1];
}
ASSERT_IN_PACKET_BOUNDS(offs);
- uint32_t load_size;
+ uint32_t load_size = 0;
switch (opcode) {
case LDB_OPCODE:
case LDBX_OPCODE:
diff --git a/v5/apf_interpreter.h b/v5/apf_interpreter.h
index 2f2d904..6ef4cc9 100644
--- a/v5/apf_interpreter.h
+++ b/v5/apf_interpreter.h
@@ -99,9 +99,9 @@ int apf_transmit_buffer(void* ctx, uint8_t* ptr, uint32_t len, uint8_t dscp);
* begins at program + program_len and ends at program + ram_len - 1,
* as described in the following diagram:
*
- *     program         program + program_len    program + ram_len
- *        |    text section    | data section    |
- *    +--------------------+------------------------+
+ * program program + program_len program + ram_len
+ * | text section | data section |
+ * +--------------------+------------------------+
*
* @param ctx - pointer to any additional context required for allocation and transmit.
may be null if no such context is required. this is opaque to