{"id":21382,"url":"https://patchwork.libcamera.org/api/1.1/patches/21382/?format=json","web_url":"https://patchwork.libcamera.org/patch/21382/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","date":"2024-09-26T10:06:40","name":"[2/2] libcamera: Replace last users of math.c","commit_ref":"8d22064082aa2c8b451a6a4cc1ea6078aa1d1ce7","pull_url":null,"state":"accepted","archived":false,"hash":"c1d90829fd082a22c3199f52b2f04ff9dd8bc3d5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21382/mbox/","series":[{"id":4630,"url":"https://patchwork.libcamera.org/api/1.1/series/4630/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4630","date":"2024-09-26T10:06:39","name":"[1/2] ipa: rpi: Replace last users of math.c","version":1,"mbox":"https://patchwork.libcamera.org/series/4630/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21382/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21382/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 48EC2C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Sep 2024 10:06:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E6C6263512;\n\tThu, 26 Sep 2024 12:06:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BD4063502\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Sep 2024 12:06:44 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C86D169;\n\tThu, 26 Sep 2024 12:05:16 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BO+zaK63\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727345116;\n\tbh=N6/1+pl6re+RDtfEJoaxQmGZZ72ipCsVNesaobraqZA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BO+zaK63FQqB/h/ZiPBTxg9h6VhwdS8RFywqlmpG6FAv3V3M8/BoE8K0FWFyR6Bkb\n\tRKQIcKsjk8pJDA2TekmqDZLqocqgA1N9JwrQVmSQFEbW+3ssOrIPP7V3WOiFefznqd\n\tDBCWjesaNya3yY/r9p1IS/a/Mvh3kwKd+W6av4ak=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Naushir Patuck <naush@raspberrypi.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH 2/2] libcamera: Replace last users of math.c","Date":"Thu, 26 Sep 2024 13:06:40 +0300","Message-ID":"<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.45.2","In-Reply-To":"<20240926100640.3504-1-laurent.pinchart@ideasonboard.com>","References":"<20240926100640.3504-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"As described in the coding style document, libcamera favours <cmath>\nover <math.h>. Replace the last few occurrences of the latter with the\nformer and adapt the code accordingly.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp   | 4 ++--\n src/libcamera/sensor/camera_sensor.cpp | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex 81a7a8ab01b8..74a5d93f88ae 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -7,8 +7,8 @@\n \n #include \"cio2.h\"\n \n+#include <cmath>\n #include <limits>\n-#include <math.h>\n \n #include <linux/media-bus-format.h>\n \n@@ -304,7 +304,7 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector<unsigned int>\n \t\t\t * comparing it with a single precision digit is enough.\n \t\t\t */\n \t\t\tratio = static_cast<unsigned int>(ratio * 10) / 10.0;\n-\t\t\tfloat ratioDiff = fabsf(ratio - desiredRatio);\n+\t\t\tfloat ratioDiff = std::abs(ratio - desiredRatio);\n \t\t\tunsigned int area = sz.width * sz.height;\n \t\t\tunsigned int areaDiff = area - desiredArea;\n \ndiff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp\nindex 4a990bb994b9..1b224f1989fe 100644\n--- a/src/libcamera/sensor/camera_sensor.cpp\n+++ b/src/libcamera/sensor/camera_sensor.cpp\n@@ -8,9 +8,9 @@\n #include \"libcamera/internal/camera_sensor.h\"\n \n #include <algorithm>\n+#include <cmath>\n #include <float.h>\n #include <limits.h>\n-#include <math.h>\n #include <string.h>\n \n #include <libcamera/base/utils.h>\n@@ -719,7 +719,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n \t\t\t\tcontinue;\n \n \t\t\tfloat ratio = static_cast<float>(sz.width) / sz.height;\n-\t\t\tfloat ratioDiff = fabsf(ratio - desiredRatio);\n+\t\t\tfloat ratioDiff = std::abs(ratio - desiredRatio);\n \t\t\tunsigned int area = sz.width * sz.height;\n \t\t\tunsigned int areaDiff = area - desiredArea;\n \n","prefixes":["2/2"]}