Skip to content

De-dup {digest_to_hex,gdb_hex_encode} code#222

Merged
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/byte_to_hex
Jul 18, 2026
Merged

De-dup {digest_to_hex,gdb_hex_encode} code#222
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/byte_to_hex

Conversation

@henrybear327

@henrybear327 henrybear327 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary by cubic

Centralized byte-to-hex encoding by adding bytes_to_hex in src/utils.h and deduplicating logic in Rosetta and the GDB stub. Behavior is unchanged: lowercase hex with a trailing NUL.

  • Refactors
    • Added inline bytes_to_hex(char *dst, const uint8_t *src, size_t len) in src/utils.h (writes len2 hex chars + NUL; returns len2).
    • Removed Rosetta’s digest_to_hex; gdb_hex_encode now wraps bytes_to_hex, and gdbstub-rsp.c includes utils.h.

Written for commit 2946f97. Summary will update on new commits.

Review in cubic

@henrybear327
henrybear327 requested a review from jserv July 17, 2026 21:26

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@henrybear327
henrybear327 force-pushed the refactor/byte_to_hex branch from b59d7c0 to 288422b Compare July 17, 2026 22:00

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henrybear327 henrybear327 changed the title Refactor duplicated byte to hex code De-dup {digest_to_hex,gdb_hex_encode} code Jul 18, 2026
@henrybear327
henrybear327 requested a review from jserv July 18, 2026 14:38
@henrybear327
henrybear327 force-pushed the refactor/byte_to_hex branch from 288422b to acca4c7 Compare July 18, 2026 14:40
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
henrybear327 force-pushed the refactor/byte_to_hex branch from acca4c7 to 2946f97 Compare July 18, 2026 18:29
@jserv
jserv merged commit 8380a1f into sysprog21:main Jul 18, 2026
10 checks passed
@henrybear327
henrybear327 deleted the refactor/byte_to_hex branch July 18, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants