[RFC,v1,01/23] libcamera: controls: Strings are arrays
diff mbox series

Message ID 20250606164156.1442682-2-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: Add `MetadataList`
Related show

Commit Message

Barnabás Pőcze June 6, 2025, 4:41 p.m. UTC
`ControlId::isArray()` and `ControlValue::isArray()` disagree
in the case of strings. Fix it by setting the static size of a
string to `libcamera::dynamic_extent` to denote a dynamically
sized array-like value.

One unfortunate side effect of this change is that if there were
string controls (there are none at the moment), then `cam` would
display them with an extra `Size: n` annotation.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=255
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/controls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi June 10, 2025, 3:22 p.m. UTC | #1
Hi Barnabás

On Fri, Jun 06, 2025 at 06:41:34PM +0200, Barnabás Pőcze wrote:
> `ControlId::isArray()` and `ControlValue::isArray()` disagree
> in the case of strings. Fix it by setting the static size of a
> string to `libcamera::dynamic_extent` to denote a dynamically
> sized array-like value.
>
> One unfortunate side effect of this change is that if there were
> string controls (there are none at the moment), then `cam` would
> display them with an extra `Size: n` annotation.
>
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=255
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

I've seen this patch multiple times already, I don't know if there was
any controversy with it, but to me it's reasonable

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  include/libcamera/controls.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 2ae4ec3d4..b170e30cb 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -98,7 +98,7 @@ struct control_type<float> {
>  template<>
>  struct control_type<std::string> {
>  	static constexpr ControlType value = ControlTypeString;
> -	static constexpr std::size_t size = 0;
> +	static constexpr std::size_t size = libcamera::dynamic_extent;
>  };
>
>  template<>
> --
> 2.49.0
>

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 2ae4ec3d4..b170e30cb 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -98,7 +98,7 @@  struct control_type<float> {
 template<>
 struct control_type<std::string> {
 	static constexpr ControlType value = ControlTypeString;
-	static constexpr std::size_t size = 0;
+	static constexpr std::size_t size = libcamera::dynamic_extent;
 };
 
 template<>