[libcamera-devel] [PATCH] libcamera: test: Fixed the compilation issue

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Jun 2 12:07:18 CEST 2020


Hi Madhavan,

On 28/05/2020 13:30, Madhavan Krishnan wrote:
> In write() function, return value is not handled and stored.
> So, we faced the compilation issue regarding this.

As mentioned by Jacopo, if you hit specific compilation problems, it
would be helpful to explain what here.

But this topic is also highlighted by our coverity scans, so I am happy
to see this one resolved all the same.

> Handled to store the return value of write() function, and
> modified the test execution based on the return values.

Please add the following tag to this patch:

Reported-by: Coverity CID=284605

> Signed-off-by: Madhavan Krishnan <madhavan.krishnan at linaro.org>
> ---
>  test/file.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/test/file.cpp b/test/file.cpp
> index 6262a6f..85eacb5 100644
> --- a/test/file.cpp
> +++ b/test/file.cpp
> @@ -27,10 +27,15 @@ protected:
>  	{
>  		fileName_ = "/tmp/libcamera.test.XXXXXX";
>  		int fd = mkstemp(&fileName_.front());
> +		ssize_t ret;
> +
>  		if (fd == -1)
>  			return TestFail;
>  
> -		write(fd, "libcamera", 9);
> +		ret = write(fd, "libcamera", 9);
> +		if(ret == -1)

Indeed, as highlighted by Jacopo, this is missing a close(fd) on this
error path.

> +			return TestFail;
> +
>  		close(fd);
>  

Alternatively, you could make the return value dependant upon ret?

		return (ret == 9) ? TestPass : TestFail;

>  		return TestPass;
> 


With the necessary updates made,

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


-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list