mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 10:25:05 +03:00
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:
parent
375fef72f8
commit
1074604c9e
1 changed files with 5 additions and 4 deletions
|
@ -107,22 +107,23 @@ int CamApp::init(int argc, char **argv)
|
||||||
std::cout << "Camera "
|
std::cout << "Camera "
|
||||||
<< std::string(options_[OptCamera])
|
<< std::string(options_[OptCamera])
|
||||||
<< " not found" << std::endl;
|
<< " not found" << std::endl;
|
||||||
cm_->stop();
|
cleanup();
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (camera_->acquire()) {
|
if (camera_->acquire()) {
|
||||||
std::cout << "Failed to acquire camera" << std::endl;
|
std::cout << "Failed to acquire camera" << std::endl;
|
||||||
camera_.reset();
|
cleanup();
|
||||||
cm_->stop();
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Using camera " << camera_->name() << std::endl;
|
std::cout << "Using camera " << camera_->name() << std::endl;
|
||||||
|
|
||||||
ret = prepareConfig();
|
ret = prepareConfig();
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
cleanup();
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptMonitor)) {
|
if (options_.isSet(OptMonitor)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue