[03/10] ipa: rpi: Define local functions in anonymous namespace
diff mbox series

Message ID 20240624192941.22943-4-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Enable -Wmissing-declarations
Related show

Commit Message

Laurent Pinchart June 24, 2024, 7:29 p.m. UTC
Multiple local functions are defined in the global namespace without the
static keyword. This compiles fine for now, but will cause a missing
declaration warning when we enable them. To prepare for that, move the
function declaration to an anonymous namespace.

While at it, for consistency, include an existing static function in the
namespace and drop the static keyword.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/rpi/controller/rpi/ccm.cpp      | 6 +++++-
 src/ipa/rpi/controller/rpi/contrast.cpp | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Kieran Bingham June 24, 2024, 9:34 p.m. UTC | #1
Quoting Laurent Pinchart (2024-06-24 20:29:34)
> Multiple local functions are defined in the global namespace without the
> static keyword. This compiles fine for now, but will cause a missing
> declaration warning when we enable them. To prepare for that, move the
> function declaration to an anonymous namespace.
> 
> While at it, for consistency, include an existing static function in the
> namespace and drop the static keyword.
> 

I'm fine with all of that, but of course this needs a tag from RPi.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/rpi/controller/rpi/ccm.cpp      | 6 +++++-
>  src/ipa/rpi/controller/rpi/contrast.cpp | 4 ++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp
> index e673964c1856..aefa580c9a4b 100644
> --- a/src/ipa/rpi/controller/rpi/ccm.cpp
> +++ b/src/ipa/rpi/controller/rpi/ccm.cpp
> @@ -113,8 +113,10 @@ void Ccm::initialise()
>  {
>  }
>  
> +namespace {
> +
>  template<typename T>
> -static bool getLocked(Metadata *metadata, std::string const &tag, T &value)
> +bool getLocked(Metadata *metadata, std::string const &tag, T &value)
>  {
>         T *ptr = metadata->getLocked<T>(tag);
>         if (ptr == nullptr)
> @@ -149,6 +151,8 @@ Matrix applySaturation(Matrix const &ccm, double saturation)
>         return Y2RGB * S * RGB2Y * ccm;
>  }
>  
> +} /* namespace */
> +
>  void Ccm::prepare(Metadata *imageMetadata)
>  {
>         bool awbOk = false, luxOk = false;
> diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp
> index 9b37943ae9c9..fe866a544293 100644
> --- a/src/ipa/rpi/controller/rpi/contrast.cpp
> +++ b/src/ipa/rpi/controller/rpi/contrast.cpp
> @@ -94,6 +94,8 @@ void Contrast::prepare(Metadata *imageMetadata)
>         imageMetadata->set("contrast.status", status_);
>  }
>  
> +namespace {
> +
>  ipa::Pwl computeStretchCurve(Histogram const &histogram,
>                         ContrastConfig const &config)
>  {
> @@ -153,6 +155,8 @@ ipa::Pwl applyManualContrast(ipa::Pwl const &gammaCurve, double brightness,
>         return newGammaCurve;
>  }
>  
> +} /* namespace */
> +
>  void Contrast::process(StatisticsPtr &stats,
>                        [[maybe_unused]] Metadata *imageMetadata)
>  {
> -- 
> Regards,
> 
> Laurent Pinchart
>
Naushir Patuck June 26, 2024, 8:53 a.m. UTC | #2
Hi Laurent,

On Mon, 24 Jun 2024 at 20:30, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Multiple local functions are defined in the global namespace without the
> static keyword. This compiles fine for now, but will cause a missing
> declaration warning when we enable them. To prepare for that, move the
> function declaration to an anonymous namespace.
>
> While at it, for consistency, include an existing static function in the
> namespace and drop the static keyword.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Looks good to me:
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>

> ---
>  src/ipa/rpi/controller/rpi/ccm.cpp      | 6 +++++-
>  src/ipa/rpi/controller/rpi/contrast.cpp | 4 ++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp
> index e673964c1856..aefa580c9a4b 100644
> --- a/src/ipa/rpi/controller/rpi/ccm.cpp
> +++ b/src/ipa/rpi/controller/rpi/ccm.cpp
> @@ -113,8 +113,10 @@ void Ccm::initialise()
>  {
>  }
>
> +namespace {
> +
>  template<typename T>
> -static bool getLocked(Metadata *metadata, std::string const &tag, T &value)
> +bool getLocked(Metadata *metadata, std::string const &tag, T &value)
>  {
>         T *ptr = metadata->getLocked<T>(tag);
>         if (ptr == nullptr)
> @@ -149,6 +151,8 @@ Matrix applySaturation(Matrix const &ccm, double saturation)
>         return Y2RGB * S * RGB2Y * ccm;
>  }
>
> +} /* namespace */
> +
>  void Ccm::prepare(Metadata *imageMetadata)
>  {
>         bool awbOk = false, luxOk = false;
> diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp
> index 9b37943ae9c9..fe866a544293 100644
> --- a/src/ipa/rpi/controller/rpi/contrast.cpp
> +++ b/src/ipa/rpi/controller/rpi/contrast.cpp
> @@ -94,6 +94,8 @@ void Contrast::prepare(Metadata *imageMetadata)
>         imageMetadata->set("contrast.status", status_);
>  }
>
> +namespace {
> +
>  ipa::Pwl computeStretchCurve(Histogram const &histogram,
>                         ContrastConfig const &config)
>  {
> @@ -153,6 +155,8 @@ ipa::Pwl applyManualContrast(ipa::Pwl const &gammaCurve, double brightness,
>         return newGammaCurve;
>  }
>
> +} /* namespace */
> +
>  void Contrast::process(StatisticsPtr &stats,
>                        [[maybe_unused]] Metadata *imageMetadata)
>  {
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp
index e673964c1856..aefa580c9a4b 100644
--- a/src/ipa/rpi/controller/rpi/ccm.cpp
+++ b/src/ipa/rpi/controller/rpi/ccm.cpp
@@ -113,8 +113,10 @@  void Ccm::initialise()
 {
 }
 
+namespace {
+
 template<typename T>
-static bool getLocked(Metadata *metadata, std::string const &tag, T &value)
+bool getLocked(Metadata *metadata, std::string const &tag, T &value)
 {
 	T *ptr = metadata->getLocked<T>(tag);
 	if (ptr == nullptr)
@@ -149,6 +151,8 @@  Matrix applySaturation(Matrix const &ccm, double saturation)
 	return Y2RGB * S * RGB2Y * ccm;
 }
 
+} /* namespace */
+
 void Ccm::prepare(Metadata *imageMetadata)
 {
 	bool awbOk = false, luxOk = false;
diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp
index 9b37943ae9c9..fe866a544293 100644
--- a/src/ipa/rpi/controller/rpi/contrast.cpp
+++ b/src/ipa/rpi/controller/rpi/contrast.cpp
@@ -94,6 +94,8 @@  void Contrast::prepare(Metadata *imageMetadata)
 	imageMetadata->set("contrast.status", status_);
 }
 
+namespace {
+
 ipa::Pwl computeStretchCurve(Histogram const &histogram,
 			ContrastConfig const &config)
 {
@@ -153,6 +155,8 @@  ipa::Pwl applyManualContrast(ipa::Pwl const &gammaCurve, double brightness,
 	return newGammaCurve;
 }
 
+} /* namespace */
+
 void Contrast::process(StatisticsPtr &stats,
 		       [[maybe_unused]] Metadata *imageMetadata)
 {