De-dup {digest_to_hex,gdb_hex_encode} code#222
Merged
Conversation
henrybear327
force-pushed
the
refactor/byte_to_hex
branch
from
July 17, 2026 22:00
b59d7c0 to
288422b
Compare
jserv
reviewed
Jul 17, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Enforce https://cbea.ms/git-commit/
henrybear327
force-pushed
the
refactor/byte_to_hex
branch
from
July 18, 2026 14:40
288422b to
acca4c7
Compare
Both rosetta's digest_to_hex and the GDB stub's gdb_hex_encode open-coded the same lowercase-hex expansion loop. Move the loop into a single bytes_to_hex helper in src/utils.h and have both call sites use it, removing the duplication without changing output. gdb_hex_encode now thinly wraps bytes_to_hex to preserve its int return convention.
henrybear327
force-pushed
the
refactor/byte_to_hex
branch
from
July 18, 2026 18:29
acca4c7 to
2946f97
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Centralized byte-to-hex encoding by adding
bytes_to_hexinsrc/utils.hand deduplicating logic in Rosetta and the GDB stub. Behavior is unchanged: lowercase hex with a trailing NUL.bytes_to_hex(char *dst, const uint8_t *src, size_t len)insrc/utils.h(writes len2 hex chars + NUL; returns len2).digest_to_hex;gdb_hex_encodenow wrapsbytes_to_hex, andgdbstub-rsp.cincludesutils.h.Written for commit 2946f97. Summary will update on new commits.