From patchwork Fri Oct 31 20:38:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24933 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 5D569BD808 for ; Fri, 31 Oct 2025 20:39:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6F96660A80; Fri, 31 Oct 2025 21:39:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UN7TC3Uj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 187F960947 for ; Fri, 31 Oct 2025 21:38:58 +0100 (CET) Received: from charm.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 DEE91558; Fri, 31 Oct 2025 21:37:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761943027; bh=VSyK8C4vNlixhgRkAwFnUO9s20tcN7u9SlFg5w7slYw=; h=From:To:Cc:Subject:Date:From; b=UN7TC3UjQx0mho94/7xDBjow0AYINjHaGTPQ6hbH8QbUHz4+qD7dcVsfh+EMgUrEy Ykn+xETTq5XQ2iHrYkXrmLr1zOWGfBvY8htxe/LrUi1VGvdF2Y5CFdpPUpyVyG8iyG H1LMIOOIuPHq2NR56tGalH3q/evIBSLUQh2DaXkE= 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 20:38:52 +0000 Message-ID: <20251031203854.19021-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 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 | 3 +- test/utils.cpp | 17 +++++++++ 3 files changed, 33 insertions(+), 55 deletions(-)