[v3,0/2] libcamera: base: utils: Prevent hex signed extension
mbox series

Message ID 20251031115216.3776845-1-kieran.bingham@ideasonboard.com
Headers show
Series
  • libcamera: base: utils: Prevent hex signed extension
Related show

Message

Kieran Bingham Oct. 31, 2025, 11:52 a.m. UTC
When converting signed values to hex strings using the utils::hex
helpers, signed negative values get sign extended to the larger 64 bit
type.

This causes values such as 0x80 to be printed as 0xffffffffffffff80
instead.

Fix this by first adding a test to catch and identify the issue, and
secondly by reconfiguring the hex adaptor to use a single templated type
which always casts to an unsigned version of the incoming type.

Kieran Bingham (2):
  test: utils: Validate hex sign extension
  libcamera: base: utils: Simplify hex adaptor

 include/libcamera/base/utils.h | 68 ++++++----------------------------
 src/libcamera/base/utils.cpp   |  2 +-
 test/utils.cpp                 | 17 +++++++++
 3 files changed, 30 insertions(+), 57 deletions(-)