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

Jacopo Mondi jacopo at jmondi.org
Mon Jun 1 09:54:32 CEST 2020


Hello Madhavan,

On Thu, May 28, 2020 at 02:30:05PM +0200, Madhavan Krishnan wrote:
> In write() function, return value is not handled and stored.
> So, we faced the compilation issue regarding this.

Which compilation error did you get ? Return value ignored ?

On which compiler ? I don't think we've seens this with latest GCC and
clang.

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

Sorry for being picky, but commit messages read better if they present
the problem and the solution (like your does) but in the present
tense. Like

"The return value of write() function is ignored, causing the following
compiler error|warning with $compiler_version

Fix this by storing the return value of write() and return a test error in
case of failure."

>
> 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);

You could delcare ret here
        ssize_t ret =

> +		if(ret == -1)
> +			return TestFail;

And you should close the fd before returning.

Anwyay, I would be interested in knowing the exact error and the
compiler version which reported it first.

Thanks
  j

> +
>  		close(fd);
>
>  		return TestPass;
> --
> 2.7.4
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel


More information about the libcamera-devel mailing list