From patchwork Fri Oct 31 11:52:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24930 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 0C4AAC3259 for ; Fri, 31 Oct 2025 11:52:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0CF38609B7; Fri, 31 Oct 2025 12:52:25 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ub7XKnYr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 14B64600CC for ; Fri, 31 Oct 2025 12:52:23 +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 372002E0; Fri, 31 Oct 2025 12:50:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761911432; bh=kMQZ8GgO6My6igDeM8KY8Hph1zQSKUq2XQr/A8uvpmU=; h=From:To:Cc:Subject:Date:From; b=ub7XKnYrlEwig89eoGCHHqvo8gMTaCHzj6gYxHTbfChc5wEnNNWLwUP99fvZgErDy xKaTvUyADvtvTEDSwCmfhWRVlmcYqba/GvG5RsdF+4SiDu8xmFfZO7qq2Zx+qHYofF Kh3zxOIntDaKk1nnGEBzIJODrGZH7+7dxGTlzypQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v3 0/2] libcamera: base: utils: Prevent hex signed extension Date: Fri, 31 Oct 2025 11:52:13 +0000 Message-ID: <20251031115216.3776845-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 | 68 ++++++---------------------------- src/libcamera/base/utils.cpp | 2 +- test/utils.cpp | 17 +++++++++ 3 files changed, 30 insertions(+), 57 deletions(-)