Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable code in dai::DataOutputQueue::get() -- unclear intention #284

Closed
diablodale opened this issue Nov 26, 2021 · 2 comments
Closed

Comments

@diablodale
Copy link
Contributor

Unreachable code in dai::DataOutputQueue::get() -- the intention is unclear. Needs a review.
On line 175-6, do you want to throw, or return nullptr. Can't do both.

std::shared_ptr<T> get() {
if(!running) throw std::runtime_error(exceptionMessage.c_str());
std::shared_ptr<ADatatype> val = nullptr;
if(!queue.waitAndPop(val)) {
throw std::runtime_error(exceptionMessage.c_str());
return nullptr;
}
return std::dynamic_pointer_cast<T>(val);
}

Setup

  • all OS
  • all compilers
  • depthai-core v2.13.2

Repro

MSVC compiler told me it is unreachable.
Verified by code review. It is unreachable.

Result

The code will throw. But it is unclear if that is the dev's intention.

Expected

Code matches dev's intention.

@themarpe
Copy link
Collaborator

return nullptr is redundant in this case - the underlying queue was destructed in this case.
If the underlying queue was destructed, then the caller is given the reason why and gets out of the blocked call.

diablodale added a commit to diablodale/depthai-core that referenced this issue Jan 16, 2022
@diablodale
Copy link
Contributor Author

verified it is merged into develop codebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants