From patchwork Fri Jun 25 21:55:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12715 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 7CF57C321A for ; Fri, 25 Jun 2021 21:56:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B9FBD684CD; Fri, 25 Jun 2021 23:56:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fjSHL7mT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6903684C9 for ; Fri, 25 Jun 2021 23:56:33 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BE074A1 for ; Fri, 25 Jun 2021 23:56:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1624658193; bh=jCAwN8tbKcjp5rdWfGzxTiTSNRX2vHsOP7rRzO1vjm8=; h=From:To:Subject:Date:From; b=fjSHL7mTH/kBMoDtMBipMLB5bJpsn52l6oudC5coDB4NYMUrHYG2/PwWwyxVFVbqZ 0h8s63eTgPMDfl7Pa7/zlZTcasraP47Vc8HEXnPiK9+NfRe2LJaB5pafcNJwOnlc3D gCkd8betGWSLpFs3hCoj2ewnLmdMRyzsgztqYl/M= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 26 Jun 2021 00:55:58 +0300 Message-Id: <20210625215558.32615-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: utils: Only enable utils::hex() for integer arguments 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" The utils::hex() function is defined as a function template that has implementations for integer arguments only. When given a different argument type, the compiler will not catch the issue, but linking will fail: src/libcamera/libcamera.so.p/camera_sensor.cpp.o: in function `libcamera::CameraSensor::validateSensorDriver()': camera_sensor.cpp:(.text+0x1e6b): undefined reference to `libcamera::utils::_hex libcamera::utils::hex(libcamera::ControlId const*, unsigned int)' Move the failure to compilation time by enabling the function for integer arguments only. This provides better diagnostics: ../../src/libcamera/camera_sensor.cpp: In member function ‘int libcamera::CameraSensor::validateSensorDriver()’: ../../src/libcamera/camera_sensor.cpp:199:77: error: no matching function for call to ‘hex(const libcamera::ControlId*&)’ Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- include/libcamera/base/utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 07685045aa05..52301254c2eb 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,8 @@ std::basic_ostream> & operator<<(std::basic_ostream> &stream, const _hex &h); #endif -template +template::value> * = nullptr> _hex hex(T value, unsigned int width = 0); #ifndef __DOXYGEN__