diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-08-04 00:49:42 +0200 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-08-05 13:01:13 +0200 |
commit | 1074604c9e2b6d9afa0247f2ca62b3140131d639 (patch) | |
tree | 96b3938e505ff36b9fd5c23986c8389965daa1e3 /src | |
parent | 375fef72f85ba9184c860c4af86013e8688896e7 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/cam/main.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index ec59e9ea..6761d638 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -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)) { |