[libcamera-devel,2/2] test: logging: fix compilation on Chromium OS

Message ID 20190712082909.3811-2-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] libcamera: process: fix compilation on Chromium OS
Related show

Commit Message

Paul Elder July 12, 2019, 8:29 a.m. UTC
Commit a25c937f8afe ("test: add logging API test") causes the build to
fail in the Chromium OS build environment, because the return value of a
system call is ignored. Fix this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 test/log.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart July 12, 2019, 8:32 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Jul 12, 2019 at 05:29:09PM +0900, Paul Elder wrote:
> Commit a25c937f8afe ("test: add logging API test") causes the build to
> fail in the Chromium OS build environment, because the return value of a
> system call is ignored. Fix this.

It's the return value of a function marked with the
__warn_unused_result__ attribute, not of anysystem call.

Fixes: a25c937f8afe ("test: add logging API test")

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

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

> ---
>  test/log.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/test/log.cpp b/test/log.cpp
> index bc64325..89fb5ca 100644
> --- a/test/log.cpp
> +++ b/test/log.cpp
> @@ -59,7 +59,10 @@ protected:
>  		char buf[1000];
>  		memset(buf, 0, sizeof(buf));
>  		lseek(fd, 0, SEEK_SET);
> -		read(fd, buf, sizeof(buf));
> +		if (read(fd, buf, sizeof(buf)) < 0) {
> +			cerr << "Failed to read tmp log file" << endl;
> +			return TestFail;
> +		}
>  		close(fd);
>  
>  		std::list<int> goodList = { 1, 3, 5 };

Patch

diff --git a/test/log.cpp b/test/log.cpp
index bc64325..89fb5ca 100644
--- a/test/log.cpp
+++ b/test/log.cpp
@@ -59,7 +59,10 @@  protected:
 		char buf[1000];
 		memset(buf, 0, sizeof(buf));
 		lseek(fd, 0, SEEK_SET);
-		read(fd, buf, sizeof(buf));
+		if (read(fd, buf, sizeof(buf)) < 0) {
+			cerr << "Failed to read tmp log file" << endl;
+			return TestFail;
+		}
 		close(fd);
 
 		std::list<int> goodList = { 1, 3, 5 };