Document public functions in parser_ext.h
What changed, and why it matters
This commit only adds documentation comments to a header file describing existing functions. No code behavior was changed, so it cannot introduce or fix a security issue on its own.
No security action needed; treat as routine documentation maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is limited to src/common/parser_ext.h and consists entirely of replacing TODO documentation placeholders with Doxygen-style comments for public functions. There are no functional code changes, no signature changes, no new logic, and no bug fixes.
Changed components
src/common/parser_ext.hInspect captured patch +62 / −10
diff --git a/src/common/parser_ext.h b/src/common/parser_ext.h
index d7f6b94..aa8314f 100644
--- a/src/common/parser_ext.h
+++ b/src/common/parser_ext.h
@@ -26,43 +26,84 @@ typedef int (*parsing_step_t)(void *, buffer_t *[2]);
// the first buffer before reading from the second buffer.
/**
- * Get the total remaining length readable from this pair of buffers.
- * TODO: finish docs
+ * Get the total number of remaining readable bytes from the concatenation of two buffers.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ *
+ * @return the sum of remaining bytes in both buffers.
*/
size_t dbuffer_get_length(buffer_t *buffers[2]);
/**
- * TODO: docs.
+ * Check whether at least n bytes can be read from the concatenation of two buffers.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[in] n Number of bytes to check for.
+ *
+ * @return true if at least n bytes remain across both buffers, false otherwise.
*/
bool dbuffer_can_read(buffer_t *buffers[2], size_t n);
/**
- * TODO: docs.
+ * Read n bytes from the concatenation of two buffers into out.
+ * Bytes are consumed from the first buffer before the second.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[out] out Destination buffer; must be at least n bytes long.
+ * @param[in] n Number of bytes to read.
+ *
+ * @return true on success, false if fewer than n bytes are available.
*/
bool dbuffer_read_bytes(buffer_t *buffers[2], uint8_t *out, size_t n);
/**
- * TODO: docs.
+ * Read a single byte from the concatenation of two buffers.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[out] out Pointer to store the read byte.
+ *
+ * @return true on success, false if no bytes are available.
*/
bool dbuffer_read_u8(buffer_t *buffers[2], uint8_t *out);
/**
- * TODO: docs.
+ * Read a 16-bit unsigned integer from the concatenation of two buffers.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[out] out Pointer to store the read value.
+ * @param[in] endianness Byte order (BE or LE).
+ *
+ * @return true on success, false if fewer than 2 bytes are available.
*/
bool dbuffer_read_u16(buffer_t *buffers[2], uint16_t *out, endianness_t endianness);
/**
- * TODO: docs.
+ * Read a 32-bit unsigned integer from the concatenation of two buffers.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[out] out Pointer to store the read value.
+ * @param[in] endianness Byte order (BE or LE).
+ *
+ * @return true on success, false if fewer than 4 bytes are available.
*/
bool dbuffer_read_u32(buffer_t *buffers[2], uint32_t *out, endianness_t endianness);
/**
- * TODO: docs.
+ * Read a Bitcoin-style variable-length integer from the concatenation of two buffers.
+ * The encoding uses 1, 3, 5, or 9 bytes depending on the value prefix.
+ *
+ * @param[in] buffers Array of two pointers to buffers.
+ * @param[out] out Pointer to store the decoded value.
+ *
+ * @return true on success, false if there are not enough bytes available.
*/
bool dbuffer_read_varint(buffer_t *buffers[2], uint64_t *out);
/**
- * TODO: docs.
+ * Initialize a parser context, resetting the step counter and setting the state pointer.
+ *
+ * @param[out] parser_context Parser context to initialize.
+ * @param[in] state Pointer to the parser-specific state structure.
*/
static inline void parser_init_context(parser_context_t *parser_context, void *state) {
parser_context->cur_step = 0;
@@ -79,7 +120,18 @@ static inline void parser_init_context(parser_context_t *parser_context, void *s
bool parser_consolidate_buffers(buffer_t *buffers[2], size_t max_size);
/**
- * TODO: docs
+ * Execute a sequence of parsing steps, resuming from the current step in the parser context.
+ * Each step is called with the parser state and the pair of buffers. Execution advances to the
+ * next step when a step returns 1, and stops when a step returns 0 (needs more data) or -1
+ * (error).
+ *
+ * @param[in] parsing_steps Array of parsing step function pointers.
+ * @param[in] n_steps Number of steps in the array.
+ * @param[in,out] parser_context Parser context tracking the current step and state.
+ * @param[in] buffers Array of two pointers to buffers containing the data to parse.
+ * @param[in] pic_fn PIC address-translation function, or NULL if not needed.
+ *
+ * @return 1 if all steps completed, 0 if more data is needed, -1 on parsing error.
*/
int parser_run(const parsing_step_t *parsing_steps,
size_t n_steps,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.