diff options
-rw-r--r-- | apf_interpreter.h | 6 | ||||
-rw-r--r-- | v5/apf_interpreter.c | 9 | ||||
-rw-r--r-- | v5/apf_interpreter.h | 6 |
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 |