[libcamera-devel,1/2] libcamera: controls: Move ControlValue size check to controls.cpp

Message ID 20200320005551.10226-1-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] libcamera: controls: Move ControlValue size check to controls.cpp
Related show

Commit Message

Laurent Pinchart March 20, 2020, 12:55 a.m. UTC
The size of the ControlValue class is checked by a static_assert() to
avoid accidental ABI breakages. There's no need to perform the check
every time controls.h is included, move it to controls.cpp.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/controls.h | 2 --
 src/libcamera/controls.cpp   | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Niklas Söderlund March 20, 2020, 12:59 a.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2020-03-20 02:55:50 +0200, Laurent Pinchart wrote:
> The size of the ControlValue class is checked by a static_assert() to
> avoid accidental ABI breakages. There's no need to perform the check
> every time controls.h is included, move it to controls.cpp.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  include/libcamera/controls.h | 2 --
>  src/libcamera/controls.cpp   | 2 ++
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 0e111ab72bce..2fca975f7512 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -170,8 +170,6 @@ private:
>  		 std::size_t numElements, std::size_t elementSize);
>  };
>  
> -static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
> -
>  class ControlId
>  {
>  public:
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 4326174adf86..4615e71d7e3c 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -83,6 +83,8 @@ static constexpr size_t ControlValueSize[] = {
>   * \brief Abstract type representing the value of a control
>   */
>  
> +static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
> +
>  /**
>   * \brief Construct an empty ControlValue.
>   */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham March 20, 2020, 12:44 p.m. UTC | #2
Hi Laurent,

On 20/03/2020 00:55, Laurent Pinchart wrote:
> The size of the ControlValue class is checked by a static_assert() to
> avoid accidental ABI breakages. There's no need to perform the check
> every time controls.h is included, move it to controls.cpp.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

LGTM.

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

> ---
>  include/libcamera/controls.h | 2 --
>  src/libcamera/controls.cpp   | 2 ++
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 0e111ab72bce..2fca975f7512 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -170,8 +170,6 @@ private:
>  		 std::size_t numElements, std::size_t elementSize);
>  };
>  
> -static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
> -
>  class ControlId
>  {
>  public:
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 4326174adf86..4615e71d7e3c 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -83,6 +83,8 @@ static constexpr size_t ControlValueSize[] = {
>   * \brief Abstract type representing the value of a control
>   */
>  
> +static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
> +
>  /**
>   * \brief Construct an empty ControlValue.
>   */
>

Patch

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 0e111ab72bce..2fca975f7512 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -170,8 +170,6 @@  private:
 		 std::size_t numElements, std::size_t elementSize);
 };
 
-static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
-
 class ControlId
 {
 public:
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 4326174adf86..4615e71d7e3c 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -83,6 +83,8 @@  static constexpr size_t ControlValueSize[] = {
  * \brief Abstract type representing the value of a control
  */
 
+static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class");
+
 /**
  * \brief Construct an empty ControlValue.
  */