From patchwork Thu Oct 30 18:11:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24926 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id ED430BE080 for ; Thu, 30 Oct 2025 18:11:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B54E608FC; Thu, 30 Oct 2025 19:11:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L6KPHZf/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F1F6608CF for ; Thu, 30 Oct 2025 19:11:32 +0100 (CET) Received: from Monstersaurus.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A85E911DD; Thu, 30 Oct 2025 19:09:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761847781; bh=4FhHUn/rA26DUBd2JoOzCUE/qmr60kA57l11fy66bmo=; h=From:To:Cc:Subject:Date:From; b=L6KPHZf/b6kiqT8hb1an+KdxRXHl9ggHmDApeXA1j2gpxZdjN8pqeAjPBDw0A/OXy yWb9eFlWZk0HbBMdKf0X7jUr9S31J4bcuoypUSfcBYxJyU3p6NozKxN8QJRbVHFi6l QFcD4c9+ltBEiso406VumBmHfGbX5hmGHeoM82Y4= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v2 0/2] libcamera: base: utils: Prevent hex signed extension Date: Thu, 30 Oct 2025 18:11:25 +0000 Message-ID: <20251030181127.1059501-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 | 66 ++++++---------------------------- src/libcamera/base/utils.cpp | 2 +- test/utils.cpp | 17 +++++++++ 3 files changed, 28 insertions(+), 57 deletions(-)