[RFC,v1,20/27] gstreamer: allocator: get_pool_size(): Fix return value
diff mbox series

Message ID 20260618123844.656396-21-barnabas.pocze@ideasonboard.com
State Accepted
Headers show
Series
  • Misc. changes before request-buffer split
Related show

Commit Message

Barnabás Pőcze June 18, 2026, 12:38 p.m. UTC
Return `0` instead of `false` in the error case.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/gstreamer/gstlibcameraallocator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi June 22, 2026, 1:47 p.m. UTC | #1
I guess false is cast to 0, but ok
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

On Thu, Jun 18, 2026 at 02:38:37PM +0200, Barnabás Pőcze wrote:
> Return `0` instead of `false` in the error case.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/gstreamer/gstlibcameraallocator.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp
> index d4492d994b..d9d771d545 100644
> --- a/src/gstreamer/gstlibcameraallocator.cpp
> +++ b/src/gstreamer/gstlibcameraallocator.cpp
> @@ -260,7 +260,7 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self,
>  	GLibLocker lock(GST_OBJECT(self));
>
>  	auto *pool = reinterpret_cast<GQueue *>(g_hash_table_lookup(self->pools, stream));
> -	g_return_val_if_fail(pool, false);
> +	g_return_val_if_fail(pool, 0);
>
>  	return pool->length;
>  }
> --
> 2.54.0
>
Nicolas Dufresne June 22, 2026, 2:41 p.m. UTC | #2
Hi,

Le lundi 22 juin 2026 à 15:47 +0200, Jacopo Mondi a écrit :
> I guess false is cast to 0, but ok
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Yes, but it remains a type miss-match, I would have expected a build warning.
Its good catch, cleaner once fixed, so I second this.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> 
> On Thu, Jun 18, 2026 at 02:38:37PM +0200, Barnabás Pőcze wrote:
> > Return `0` instead of `false` in the error case.
> > 
> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > ---
> >  src/gstreamer/gstlibcameraallocator.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp
> > index d4492d994b..d9d771d545 100644
> > --- a/src/gstreamer/gstlibcameraallocator.cpp
> > +++ b/src/gstreamer/gstlibcameraallocator.cpp
> > @@ -260,7 +260,7 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self,
> >  	GLibLocker lock(GST_OBJECT(self));
> > 
> >  	auto *pool = reinterpret_cast<GQueue *>(g_hash_table_lookup(self->pools, stream));
> > -	g_return_val_if_fail(pool, false);
> > +	g_return_val_if_fail(pool, 0);
> > 
> >  	return pool->length;
> >  }
> > --
> > 2.54.0
> >
Laurent Pinchart June 23, 2026, 9:59 p.m. UTC | #3
On Thu, Jun 18, 2026 at 02:38:37PM +0200, Barnabás Pőcze wrote:
> Return `0` instead of `false` in the error case.

I'd add "as the function's return type is gsize".

> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

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

> ---
>  src/gstreamer/gstlibcameraallocator.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp
> index d4492d994b..d9d771d545 100644
> --- a/src/gstreamer/gstlibcameraallocator.cpp
> +++ b/src/gstreamer/gstlibcameraallocator.cpp
> @@ -260,7 +260,7 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self,
>  	GLibLocker lock(GST_OBJECT(self));
>  
>  	auto *pool = reinterpret_cast<GQueue *>(g_hash_table_lookup(self->pools, stream));
> -	g_return_val_if_fail(pool, false);
> +	g_return_val_if_fail(pool, 0);
>  
>  	return pool->length;
>  }

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp
index d4492d994b..d9d771d545 100644
--- a/src/gstreamer/gstlibcameraallocator.cpp
+++ b/src/gstreamer/gstlibcameraallocator.cpp
@@ -260,7 +260,7 @@  gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self,
 	GLibLocker lock(GST_OBJECT(self));
 
 	auto *pool = reinterpret_cast<GQueue *>(g_hash_table_lookup(self->pools, stream));
-	g_return_val_if_fail(pool, false);
+	g_return_val_if_fail(pool, 0);
 
 	return pool->length;
 }