Message ID | 1591130194-5161-1-git-send-email-madhavan.krishnan@linaro.org |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Madhavan, Thank you for the patch. No need to prefix the subject line with 'libcamera:' for the tests. On Tue, Jun 02, 2020 at 10:36:34PM +0200, Madhavan Krishnan wrote: > The return value of write() function is ignored, causing the following > compiler error|warning with gcc version 5.4 > > error: ignoring return value of 'ssize_t write(int, const void*, size_t)' > > Fix this by storing the return value of write() and return a test error in > case of failure. > > Reported-by: Coverity CID=284605 > > Signed-off-by: Madhavan Krishnan <madhavan.krishnan@linaro.org> > --- > test/file.cpp | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/test/file.cpp b/test/file.cpp > index 6262a6f..e328c01 100644 > --- a/test/file.cpp > +++ b/test/file.cpp > @@ -27,13 +27,16 @@ 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 can declare the ret variable on the same line. > + > close(fd); > > - return TestPass; > + return ret == 9? TestPass : TestFail; Missing space after 9. I'll fix when applying, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > } > > int run()
diff --git a/test/file.cpp b/test/file.cpp index 6262a6f..e328c01 100644 --- a/test/file.cpp +++ b/test/file.cpp @@ -27,13 +27,16 @@ 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); + close(fd); - return TestPass; + return ret == 9? TestPass : TestFail; } int run()
The return value of write() function is ignored, causing the following compiler error|warning with gcc version 5.4 error: ignoring return value of 'ssize_t write(int, const void*, size_t)' Fix this by storing the return value of write() and return a test error in case of failure. Reported-by: Coverity CID=284605 Signed-off-by: Madhavan Krishnan <madhavan.krishnan@linaro.org> --- test/file.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)