Commit fcf7b4c
authored
[spi-hdlc-adapter] define explicit worst-case HDLC frame size macro (openthread#13237)
This commit replaces the implicit sizing of `escaped_frame_buffer`
with an explicit macro `HDLC_MAX_FRAME_SIZE` in the standalone
`spi-hdlc-adapter` tool.
Previously, `escaped_frame_buffer` was sized statically to
`MAX_FRAME_SIZE * 2` (4096 bytes). While this size is mathematically
sufficient to hold a worst-case escaped payload (4091 bytes for a
2043-byte max payload, 4 escaped CRC bytes, and 1 flag byte), it was
not self-documenting and relied on implicit math.
This commit defines `HDLC_MAX_FRAME_SIZE` explicitly as:
`((MAX_FRAME_SIZE - HEADER_LEN) * 2 + 5)`
making the worst-case framing overhead bounds clear and robust to
any future changes to the constants.1 parent 11acd4a commit fcf7b4c
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
803 | 804 | | |
804 | 805 | | |
805 | 806 | | |
806 | | - | |
| 807 | + | |
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
| |||
0 commit comments