[PATCH v1] libcamera: media_device: Ignore `lockf()` return value

Kieran Bingham kieran.bingham at ideasonboard.com
Mon Mar 17 22:45:04 CET 2025


Quoting Barnabás Pőcze (2025-03-17 18:11:34)
> When `_FORTIFY_SOURCE` is enabled, the `lockf()` function might be marked
> with the `warn_unused_result` attribute, leading to compilation failure.
> Fix that by explicitly ignoring the return value.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>

I didn't know about std::ignore.

Looks appropriate here...

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

> ---
>  src/libcamera/media_device.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index d71dad74d..75abd91d7 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -13,6 +13,7 @@
>  #include <string>
>  #include <string.h>
>  #include <sys/ioctl.h>
> +#include <tuple>
>  #include <unistd.h>
>  #include <vector>
>  
> @@ -164,7 +165,7 @@ void MediaDevice::unlock()
>         if (!fd_.isValid())
>                 return;
>  
> -       lockf(fd_.get(), F_ULOCK, 0);
> +       std::ignore = lockf(fd_.get(), F_ULOCK, 0);
>  }
>  
>  /**
> -- 
> 2.49.0
>


More information about the libcamera-devel mailing list