[libcamera-devel] kms: void-cast 'request' to avoid 'unused-parameter' warnings
diff mbox series

Message ID 20221118200046.51305-1-Rauch.Christian@gmx.de
State New
Headers show
Series
  • [libcamera-devel] kms: void-cast 'request' to avoid 'unused-parameter' warnings
Related show

Commit Message

Christian Rauch Nov. 18, 2022, 8 p.m. UTC
The parameter 'request' is only used in an assert. assert is only defined
for debug builds and release builds will not use the parameter, resulting
in warnings messages only for non-debug builds.
Fix this by a no-op void cast.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
---
 src/apps/cam/kms_sink.cpp | 1 +
 1 file changed, 1 insertion(+)

--
2.34.1

Comments

Laurent Pinchart Nov. 18, 2022, 8:10 p.m. UTC | #1
Hi Christian,

Thank you for the patch.

On Fri, Nov 18, 2022 at 09:00:46PM +0100, Christian Rauch via libcamera-devel wrote:
> The parameter 'request' is only used in an assert. assert is only defined
> for debug builds and release builds will not use the parameter, resulting
> in warnings messages only for non-debug builds.
> Fix this by a no-op void cast.
> 
> Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
> ---
>  src/apps/cam/kms_sink.cpp | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
> index 754b061e..de0af51e 100644
> --- a/src/apps/cam/kms_sink.cpp
> +++ b/src/apps/cam/kms_sink.cpp
> @@ -521,6 +521,7 @@ void KMSSink::requestComplete(DRM::AtomicRequest *request)
>  {
>  	std::lock_guard<std::mutex> lock(lock_);
> 
> +	(void) request;

The standard way to do this in C++ is to declare the function as

void KMSSink::requestComplete([[maybe_unused]] DRM::AtomicRequest *request)

>  	assert(queued_ && queued_->drmRequest_.get() == request);
> 
>  	/* Complete the active request, if any. */

Patch
diff mbox series

diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
index 754b061e..de0af51e 100644
--- a/src/apps/cam/kms_sink.cpp
+++ b/src/apps/cam/kms_sink.cpp
@@ -521,6 +521,7 @@  void KMSSink::requestComplete(DRM::AtomicRequest *request)
 {
 	std::lock_guard<std::mutex> lock(lock_);

+	(void) request;
 	assert(queued_ && queued_->drmRequest_.get() == request);

 	/* Complete the active request, if any. */