cam: Use the common cleanup function on failure
The different error paths in init() are out of sync. Instead of fixing them switch to using the cleanup() function which does the right thing for all cases. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
+5
-4
@@ -107,22 +107,23 @@ int CamApp::init(int argc, char **argv)
|
||||
std::cout << "Camera "
|
||||
<< std::string(options_[OptCamera])
|
||||
<< " not found" << std::endl;
|
||||
cm_->stop();
|
||||
cleanup();
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (camera_->acquire()) {
|
||||
std::cout << "Failed to acquire camera" << std::endl;
|
||||
camera_.reset();
|
||||
cm_->stop();
|
||||
cleanup();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
std::cout << "Using camera " << camera_->name() << std::endl;
|
||||
|
||||
ret = prepareConfig();
|
||||
if (ret)
|
||||
if (ret) {
|
||||
cleanup();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (options_.isSet(OptMonitor)) {
|
||||
|
||||
Reference in New Issue
Block a user