mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:53:23 +00:00
cleanup: fix over-eager Coverity warnings
Technically get_dive() could return a nullptr. The existing code made sure the argument passed to get_dive() was one that always would result in a valid dive pointer being returned. The new code is only slightly less efficient but allows a static code analysis to easily see that we don't derefence NULL pointers here. On some level this change is unnecessary. But it's also not wrong. Fixes CID 354762 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e30ba8a8e0
commit
8e330f297e
1 changed files with 4 additions and 2 deletions
|
@ -74,10 +74,12 @@ bool is_trip_before_after(const struct dive *dive, bool before)
|
||||||
{
|
{
|
||||||
int idx = get_idx_by_uniq_id(dive->id);
|
int idx = get_idx_by_uniq_id(dive->id);
|
||||||
if (before) {
|
if (before) {
|
||||||
if (idx > 0 && get_dive(idx - 1)->divetrip)
|
const struct dive *d = get_dive(idx - 1);
|
||||||
|
if (d && d->divetrip)
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (idx < dive_table.nr - 1 && get_dive(idx + 1)->divetrip)
|
const struct dive *d = get_dive(idx + 1);
|
||||||
|
if (d && d->divetrip)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue