[libcamera-devel,v2,2/2] test: v4l2_videodevice: buffer_cache: Fail the test if no hot-buffer is obtained

Message ID 20200415054503.13108-3-email@uajain.com
State Rejected
Delegated to: Umang Jain
Headers show
Series
  • More coverity scan fixes
Related show

Commit Message

Umang Jain April 15, 2020, 5:45 a.m. UTC
Pointed out by Coverity DefectId=279090

Signed-off-by: Umang Jain <email@uajain.com>
---
 test/v4l2_videodevice/buffer_cache.cpp | 5 +++++
 1 file changed, 5 insertions(+)

Patch

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