[libcamera-devel] [PATCH 3/3] test: v4l2_videodevice: buffer_cache: Fail the test if no buffer from cache is obtained
Umang Jain
email at uajain.com
Tue Apr 14 09:06:59 CEST 2020
Failing the test guards against negative index (-ENOENT in this case)
being passed to V4L2BufferCache::put().
Pointed out by Coverity DefectId=279090
Signed-off-by: Umang Jain <email at uajain.com>
---
test/v4l2_videodevice/buffer_cache.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp
index d730e75..1870249 100644
--- a/test/v4l2_videodevice/buffer_cache.cpp
+++ b/test/v4l2_videodevice/buffer_cache.cpp
@@ -90,6 +90,11 @@ public:
/* Pick a hot buffer at random and store its index. */
int hotBuffer = dist(generator_);
int hotIndex = cache->get(*buffers[hotBuffer].get());
+ if (hotIndex < 0) {
+ std::cout << "Failed lookup from cache" << std::endl;
+ return TestFail;
+ }
+
cache->put(hotIndex);
/*
--
2.26.0
More information about the libcamera-devel
mailing list