ipa: libipa: matrix: Fix incorrect symbol namespace
diff mbox series

Message ID 20240621152334.30139-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 2119bdac6a011034cc33584e3303e47db4932313
Headers show
Series
  • ipa: libipa: matrix: Fix incorrect symbol namespace
Related show

Commit Message

Laurent Pinchart June 21, 2024, 3:23 p.m. UTC
The matrixVlidateYaml() function is declared in the libcamera::ipa::
namespace, but defined in the libcamera:: namespace. This causes a
dynamic linking error at runtime. Fix it by moving the function
definition.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/libipa/matrix.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi June 21, 2024, 4:06 p.m. UTC | #1
Hi Laurent

On Fri, Jun 21, 2024 at 06:23:34PM GMT, Laurent Pinchart wrote:
> The matrixVlidateYaml() function is declared in the libcamera::ipa::
> namespace, but defined in the libcamera:: namespace. This causes a
> dynamic linking error at runtime. Fix it by moving the function
> definition.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks, it fixes the symbol lookup issue on my setup
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

> ---
>  src/ipa/libipa/matrix.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/ipa/libipa/matrix.cpp b/src/ipa/libipa/matrix.cpp
> index 7f000382d33b..8346f0d34160 100644
> --- a/src/ipa/libipa/matrix.cpp
> +++ b/src/ipa/libipa/matrix.cpp
> @@ -122,8 +122,6 @@ namespace ipa {
>   * \return Matrix sum of matrices \a m1 and \a m2
>   */
>
> -} /* namespace ipa */
> -
>  #ifndef __DOXYGEN__
>  /*
>   * The YAML data shall be a list of numerical values. Its size shall be equal
> @@ -146,4 +144,6 @@ bool matrixValidateYaml(const YamlObject &obj, unsigned int size)
>  }
>  #endif /* __DOXYGEN__ */
>
> +} /* namespace ipa */
> +
>  } /* namespace libcamera */
> --
> Regards,
>
> Laurent Pinchart
>
Barnabás Pőcze June 21, 2024, 4:24 p.m. UTC | #2
2024. június 21., péntek 17:23 keltezéssel, Laurent Pinchart <laurent.pinchart@ideasonboard.com> írta:

> The matrixVlidateYaml() function is declared in the libcamera::ipa::
> namespace, but defined in the libcamera:: namespace. This causes a
> dynamic linking error at runtime. Fix it by moving the function
> definition.

`-Werror=missing-declarations` can catch this. Although it needs the following change
as well to build:

diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index b5775e49..7da62b51 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -48,6 +49,7 @@ private:
 extern const LogCategory &_LOG_CATEGORY(name)();
 
 #define LOG_DEFINE_CATEGORY(name)                                      \
+LOG_DECLARE_CATEGORY(name)                                             \
 const LogCategory &_LOG_CATEGORY(name)()                               \
 {                                                                      \
        /* The instance will be deleted by the Logger destructor. */    \


Regards,
Barnabás Pőcze


> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/libipa/matrix.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/libipa/matrix.cpp b/src/ipa/libipa/matrix.cpp
> index 7f000382d33b..8346f0d34160 100644
> --- a/src/ipa/libipa/matrix.cpp
> +++ b/src/ipa/libipa/matrix.cpp
> @@ -122,8 +122,6 @@ namespace ipa {
>   * \return Matrix sum of matrices \a m1 and \a m2
>   */
> 
> -} /* namespace ipa */
> -
>  #ifndef __DOXYGEN__
>  /*
>   * The YAML data shall be a list of numerical values. Its size shall be equal
> @@ -146,4 +144,6 @@ bool matrixValidateYaml(const YamlObject &obj, unsigned int size)
>  }
>  #endif /* __DOXYGEN__ */
> 
> +} /* namespace ipa */
> +
>  } /* namespace libcamera */
> --
> Regards,
> 
> Laurent Pinchart
>
Paul Elder June 24, 2024, 6:06 a.m. UTC | #3
On Fri, Jun 21, 2024 at 06:23:34PM +0300, Laurent Pinchart wrote:
> The matrixVlidateYaml() function is declared in the libcamera::ipa::

s/Vlidate/Validate/

> namespace, but defined in the libcamera:: namespace. This causes a
> dynamic linking error at runtime. Fix it by moving the function
> definition.

Oops...

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/ipa/libipa/matrix.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/libipa/matrix.cpp b/src/ipa/libipa/matrix.cpp
> index 7f000382d33b..8346f0d34160 100644
> --- a/src/ipa/libipa/matrix.cpp
> +++ b/src/ipa/libipa/matrix.cpp
> @@ -122,8 +122,6 @@ namespace ipa {
>   * \return Matrix sum of matrices \a m1 and \a m2
>   */
>  
> -} /* namespace ipa */
> -
>  #ifndef __DOXYGEN__
>  /*
>   * The YAML data shall be a list of numerical values. Its size shall be equal
> @@ -146,4 +144,6 @@ bool matrixValidateYaml(const YamlObject &obj, unsigned int size)
>  }
>  #endif /* __DOXYGEN__ */
>  
> +} /* namespace ipa */
> +
>  } /* namespace libcamera */
Laurent Pinchart June 24, 2024, 8:03 a.m. UTC | #4
Hi Barnabás,

On Fri, Jun 21, 2024 at 04:24:41PM +0000, Barnabás Pőcze wrote:
> 2024. június 21., péntek 17:23 keltezéssel, Laurent Pinchart <laurent.pinchart@ideasonboard.com> írta:
> 
> > The matrixVlidateYaml() function is declared in the libcamera::ipa::
> > namespace, but defined in the libcamera:: namespace. This causes a
> > dynamic linking error at runtime. Fix it by moving the function
> > definition.
> 
> `-Werror=missing-declarations` can catch this. Although it needs the following change
> as well to build:
> 
> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
> index b5775e49..7da62b51 100644
> --- a/include/libcamera/base/log.h
> +++ b/include/libcamera/base/log.h
> @@ -48,6 +49,7 @@ private:
>  extern const LogCategory &_LOG_CATEGORY(name)();
>  
>  #define LOG_DEFINE_CATEGORY(name)                                      \
> +LOG_DECLARE_CATEGORY(name)                                             \
>  const LogCategory &_LOG_CATEGORY(name)()                               \
>  {                                                                      \
>         /* The instance will be deleted by the Logger destructor. */    \
> 

That's a great idea. We considered in the past changing linker options
to try and get the link to fail at build time but there were some
drawbacks (I don't recall the exact details). Adding
-Werror=missing-declarations may not catch all problems, but it should
help quite a bit (it would have caught this issue) without any real
downside. I'll send a patch.

> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/ipa/libipa/matrix.cpp | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/ipa/libipa/matrix.cpp b/src/ipa/libipa/matrix.cpp
> > index 7f000382d33b..8346f0d34160 100644
> > --- a/src/ipa/libipa/matrix.cpp
> > +++ b/src/ipa/libipa/matrix.cpp
> > @@ -122,8 +122,6 @@ namespace ipa {
> >   * \return Matrix sum of matrices \a m1 and \a m2
> >   */
> > 
> > -} /* namespace ipa */
> > -
> >  #ifndef __DOXYGEN__
> >  /*
> >   * The YAML data shall be a list of numerical values. Its size shall be equal
> > @@ -146,4 +144,6 @@ bool matrixValidateYaml(const YamlObject &obj, unsigned int size)
> >  }
> >  #endif /* __DOXYGEN__ */
> > 
> > +} /* namespace ipa */
> > +
> >  } /* namespace libcamera */

Patch
diff mbox series

diff --git a/src/ipa/libipa/matrix.cpp b/src/ipa/libipa/matrix.cpp
index 7f000382d33b..8346f0d34160 100644
--- a/src/ipa/libipa/matrix.cpp
+++ b/src/ipa/libipa/matrix.cpp
@@ -122,8 +122,6 @@  namespace ipa {
  * \return Matrix sum of matrices \a m1 and \a m2
  */
 
-} /* namespace ipa */
-
 #ifndef __DOXYGEN__
 /*
  * The YAML data shall be a list of numerical values. Its size shall be equal
@@ -146,4 +144,6 @@  bool matrixValidateYaml(const YamlObject &obj, unsigned int size)
 }
 #endif /* __DOXYGEN__ */
 
+} /* namespace ipa */
+
 } /* namespace libcamera */