[{"id":31397,"web_url":"https://patchwork.libcamera.org/comment/31397/","msgid":"<172734695799.3726802.11077203895927905150@ping.linuxembedded.co.uk>","date":"2024-09-26T10:35:57","subject":"Re: [PATCH 2/2] libcamera: Replace last users of math.c","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"in $SUBJECT s/c$/h/\n\nQuoting Laurent Pinchart (2024-09-26 11:06:40)\n> As described in the coding style document, libcamera favours <cmath>\n> over <math.h>. Replace the last few occurrences of the latter with the\n> former and adapt the code accordingly.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\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(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 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>                          * comparing it with a single precision digit is enough.\n>                          */\n>                         ratio = static_cast<unsigned int>(ratio * 10) / 10.0;\n> -                       float ratioDiff = fabsf(ratio - desiredRatio);\n> +                       float ratioDiff = std::abs(ratio - desiredRatio);\n>                         unsigned int area = sz.width * sz.height;\n>                         unsigned int areaDiff = area - desiredArea;\n>  \n> diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp\n> index 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>                                 continue;\n>  \n>                         float ratio = static_cast<float>(sz.width) / sz.height;\n> -                       float ratioDiff = fabsf(ratio - desiredRatio);\n> +                       float ratioDiff = std::abs(ratio - desiredRatio);\n>                         unsigned int area = sz.width * sz.height;\n>                         unsigned int areaDiff = area - desiredArea;\n>  \n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 01037C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Sep 2024 10:36:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 444F26350F;\n\tThu, 26 Sep 2024 12:36:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 68A0C634F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Sep 2024 12:36:00 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E686169;\n\tThu, 26 Sep 2024 12:34:32 +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=\"VXbaQ0ob\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727346872;\n\tbh=iDAX1c3gJvrWF5WsLMx52S9jqt96treuIUuMqUgF3/g=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=VXbaQ0obfEXqlpDGSd+NXuxgPLmSJfFLL5rfP+I8ULPamPBj8wTrc+X0UygFkEPT7\n\tNoyj6e/+6IRxZL+WNvfkQ+rWdVo7Bh9+I+TxR7dNhJFntZ/bsKE0zxv4+R0C9J+WlF\n\t/wI0qUI78Uqup1M1hIh+81sLfaD5WxYdBu7vhKoQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","References":"<20240926100640.3504-1-laurent.pinchart@ideasonboard.com>\n\t<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH 2/2] libcamera: Replace last users of math.c","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Naushir Patuck <naush@raspberrypi.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 26 Sep 2024 11:35:57 +0100","Message-ID":"<172734695799.3726802.11077203895927905150@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":31461,"web_url":"https://patchwork.libcamera.org/comment/31461/","msgid":"<CAEmqJPrAcRE+be1NnzAgZ8DOmwF77AqYxyRFv-Rgwn7k4kFY8w@mail.gmail.com>","date":"2024-09-30T07:34:35","subject":"Re: [PATCH 2/2] libcamera: Replace last users of math.c","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Thu, 26 Sept 2024 at 11:06, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> As described in the coding style document, libcamera favours <cmath>\n> over <math.h>. Replace the last few occurrences of the latter with the\n> former and adapt the code accordingly.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\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(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 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>                          * comparing it with a single precision digit is enough.\n>                          */\n>                         ratio = static_cast<unsigned int>(ratio * 10) / 10.0;\n> -                       float ratioDiff = fabsf(ratio - desiredRatio);\n> +                       float ratioDiff = std::abs(ratio - desiredRatio);\n>                         unsigned int area = sz.width * sz.height;\n>                         unsigned int areaDiff = area - desiredArea;\n>\n> diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp\n> index 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>                                 continue;\n>\n>                         float ratio = static_cast<float>(sz.width) / sz.height;\n> -                       float ratioDiff = fabsf(ratio - desiredRatio);\n> +                       float ratioDiff = std::abs(ratio - desiredRatio);\n>                         unsigned int area = sz.width * sz.height;\n>                         unsigned int areaDiff = area - desiredArea;\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 DEA2FC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Sep 2024 07:34:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D65E63516;\n\tMon, 30 Sep 2024 09:34:57 +0200 (CEST)","from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com\n\t[IPv6:2607:f8b0:4864:20::112b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A1B163510\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 09:34:54 +0200 (CEST)","by mail-yw1-x112b.google.com with SMTP id\n\t00721157ae682-6dc7280e238so2652307b3.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 00:34:54 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"oxCX6GQC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1727681693; x=1728286493;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=ZjX3xowZFWubfqtd4XxRokFUmxMEN+sBGdV3qGGkSA8=;\n\tb=oxCX6GQCC2AfMRSrPauBgWK1yb8d4kuYMNWXkm+ILd3eC0tTcVOFRDmwYN9lI5v9nF\n\to29EYXyRHZ6cMVCTN9/sgESQU3XFJC2Qs9FTGkL474v2Gccog9ADNMom0DUevucNoJf9\n\tcSPzslIboakj9jGydIpC+kNUHwHK+tygqzjDTfw7g0tg3N+aSqaRljyLoNguSkXXFgDr\n\ts68HNecQJamcP4gC/SPWrRAF3VCckVQTPXBGSJp5VmKMqKkRcnpBuiPKRE84GdWhSJYc\n\tOydZHd3EvIcBye+MrjJOWNeY0mVTuv9K4mSM5gX966DCCadXy/pbSafeUVGi21rRgNi7\n\tsTsQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1727681693; x=1728286493;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=ZjX3xowZFWubfqtd4XxRokFUmxMEN+sBGdV3qGGkSA8=;\n\tb=c2vEVVUbfejYJrUAb9sk4bODP09kq97cHGqcEQT3uCugW8D4k325Mune7dTRMcbonX\n\t+YTvuOs/otnir12zpr8vM2RgZ9xOJsUYHztS6uArmvvfU9hmA19F5e8y+rWCGEB4bxuM\n\t463oA+N2NrnM9SjMxaT10qLmPAnERiDW37u5CUtXDCtG0HN7Qz2tdVgt9kbTMwcTn3ra\n\tqz4sT2QB/7WvSkSPeB4QIx++LRWLF4VhMSU3Ob9b7woPyHLdW9Kv7fEjCmJ5mTHgQMCF\n\tFR1VGwkUVtrdLG12khtrHbmJQ3afFxuCs33wFysGi6A4lN1/cds6VO2TUuG9lfUxox4r\n\toomg==","X-Gm-Message-State":"AOJu0YwIwoTaZ3pQfdSwpPKuhcJvd1U6P67fkrIVMkWbe1LgpAG2mBFG\n\tGCTTVrH2i3VK2oGUJJMRZIorMAPXpus5hRSFOj97CAgg3UwY/VE2b5wanyzDFkZy7mbLcW3Irmc\n\ttG5CfhK6mOpGsmywQJjhnB2Kjg4I/+H5J3KNBsQxVCWfieK9FPcw=","X-Google-Smtp-Source":"AGHT+IF2iSiV+HhjivqQMxxOQUjlfgPboKIFQ4VPr8JSaxKqcTG6tW/t5+6JGw6oNF67iumXNXWURhcYmJ+Ef+AQQnY=","X-Received":"by 2002:a05:690c:398:b0:6d3:c7d:5eaa with SMTP id\n\t00721157ae682-6e258e53647mr16666567b3.8.1727681693551;\n\tMon, 30 Sep 2024 00:34:53 -0700 (PDT)","MIME-Version":"1.0","References":"<20240926100640.3504-1-laurent.pinchart@ideasonboard.com>\n\t<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20240926100640.3504-2-laurent.pinchart@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Mon, 30 Sep 2024 08:34:35 +0100","Message-ID":"<CAEmqJPrAcRE+be1NnzAgZ8DOmwF77AqYxyRFv-Rgwn7k4kFY8w@mail.gmail.com>","Subject":"Re: [PATCH 2/2] libcamera: Replace last users of math.c","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tDavid Plowman <david.plowman@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","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>"}}]