[libcamera-devel,1/2] test: fence: Check write return value
diff mbox series

Message ID 20211213145143.218734-2-jacopo@jmondi.org
State Accepted
Commit a3122eeceafae4f37346ec40f24d20706473e962
Headers show
Series
  • test: fence: Fixes for the fence test
Related show

Commit Message

Jacopo Mondi Dec. 13, 2021, 2:51 p.m. UTC
The ::write() function used to signal a framebuffer fence in the unit
test is marked with the 'warn_unused_result'.

When building in debugoptimized mode not checking for the return
value causes issues at build time:
/test/fence.cpp:254:2: error: ignoring return value of function declared with 'warn_unused_result' attribute

Fix that by checking the ::write() return value and emitting an
error message in case the write fails.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 test/fence.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Dec. 13, 2021, 3:09 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Mon, Dec 13, 2021 at 03:51:42PM +0100, Jacopo Mondi wrote:
> The ::write() function used to signal a framebuffer fence in the unit
> test is marked with the 'warn_unused_result'.
> 
> When building in debugoptimized mode not checking for the return
> value causes issues at build time:
> /test/fence.cpp:254:2: error: ignoring return value of function declared with 'warn_unused_result' attribute
> 
> Fix that by checking the ::write() return value and emitting an
> error message in case the write fails.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  test/fence.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/test/fence.cpp b/test/fence.cpp
> index d2dfc9b615a9..d2865398784e 100644
> --- a/test/fence.cpp
> +++ b/test/fence.cpp
> @@ -251,7 +251,12 @@ void FenceTest::requestComplete(Request *request)
>  void FenceTest::signalFence()
>  {
>  	uint64_t value = 1;
> -	write(efd2_, &value, sizeof(value));
> +	int ret;
> +
> +	ret = write(efd2_, &value, sizeof(value));
> +	if (ret != sizeof(value))
> +		cerr << "Failed to signal fence" << endl;
> +
>  	dispatcher_->processEvents();
>  }
>
Umang Jain Dec. 13, 2021, 3:39 p.m. UTC | #2
Hi Jacopo,

Thanks for the patch.

On 12/13/21 8:21 PM, Jacopo Mondi wrote:
> The ::write() function used to signal a framebuffer fence in the unit
> test is marked with the 'warn_unused_result'.
>
> When building in debugoptimized mode not checking for the return
> value causes issues at build time:
> /test/fence.cpp:254:2: error: ignoring return value of function declared with 'warn_unused_result' attribute
>
> Fix that by checking the ::write() return value and emitting an
> error message in case the write fails.
>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>


Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   test/fence.cpp | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/fence.cpp b/test/fence.cpp
> index d2dfc9b615a9..d2865398784e 100644
> --- a/test/fence.cpp
> +++ b/test/fence.cpp
> @@ -251,7 +251,12 @@ void FenceTest::requestComplete(Request *request)
>   void FenceTest::signalFence()
>   {
>   	uint64_t value = 1;
> -	write(efd2_, &value, sizeof(value));
> +	int ret;
> +
> +	ret = write(efd2_, &value, sizeof(value));
> +	if (ret != sizeof(value))
> +		cerr << "Failed to signal fence" << endl;
> +
>   	dispatcher_->processEvents();
>   }
>

Patch
diff mbox series

diff --git a/test/fence.cpp b/test/fence.cpp
index d2dfc9b615a9..d2865398784e 100644
--- a/test/fence.cpp
+++ b/test/fence.cpp
@@ -251,7 +251,12 @@  void FenceTest::requestComplete(Request *request)
 void FenceTest::signalFence()
 {
 	uint64_t value = 1;
-	write(efd2_, &value, sizeof(value));
+	int ret;
+
+	ret = write(efd2_, &value, sizeof(value));
+	if (ret != sizeof(value))
+		cerr << "Failed to signal fence" << endl;
+
 	dispatcher_->processEvents();
 }