The current code of course works just fine. But there's a risk someone might
add something to one of these cases and not realize that there is an implicit
fall through going on. This is cleaner.
Found by Coverity. Fixes CID 350079
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should never matter as we should never call undoit before redoit.
Extra ensurance that we don't access random data.
Found by Coverity. Fixes CID 350076
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This seems excessively unlikely to actually fail. SEEK_END works, but SEEK_SET
fails? Oh well. Belts and suspenders.
Found by Coverity. Fixes CID 45039
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This one is a bit complicated as it depends on a specific flow, but it
seems like setup_cvs_parms might indeed write NULL to the element at
index 49 of parm. I'm not 100% sure that the sequence of events required
for this can happen, but adding one more pointer to the array seems like
cheap insurance.
Found by Coverity. Fixes CID 350120
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This prevents a resource leak.
Found by Coverity. Fixes CID 350080
The commit also includes some tiny whitespace/empty line fixes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I missed one file fixing this earlier.
Since we never did anything with the error string, why even ask for it.
And this way we don't have to deal with the memory returned, either.
Found by Coverity. Fixes CID 350082
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
transfer.sh has suddenly started to time out. And for the rather
occasional need of having a binary to test from a PR, this should be
good enough.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is extremely unlikely to ever happen since we reserve space for a
hundred weight models, but hey, doing this right is quite easy, so let's
fix it.
Found by Coverity. Fixes CID #350117
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we never did anything with the error string, why even ask for it.
And this way we don't have to deal with the memory returned, either.
Found by Coverity. Fixes CIDs 350124, 350113, 350106, 350099, 350091
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Even if there is a valid trip, we should not add a structure that isn't
a dive to it.
Found by Coverity. Fixes CID #350073
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Free resources allocated by alloc_dive() with free_dive().
Don't allocate and re-allocate a fixed two byte buffer on the heap.
Indirectly this fixes CID 216616
Suggested-by; Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this is debatably correct, free will happily accept (and ignore
the NULL pointer), so let's just always call it and make Coverity happy.
Fixes CID 45163
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Due to some recent changes processing the downloaded dives and
re-displaying the dive list can take quite a while. So show a small
message and the busy spinner to warn the user.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code was ill named - this way the busy spinner itself
becomes reusable with a reasonable set of function names.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way new fixes are actually shown when the user looks at the dive
list after applying the GPS fixes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The profile repainting code that was called when a dive changed was
located in a separate function. Not only did it take a redundant
parameter, it also performed very weird stuff like entering and
exiting plan state. That did not work at all. Replace by a simple
call to plotDive() and things work much better.
There was a comment about DivePlannerPointsModel and profile
getting out of sync. So let's keep an eye out for that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The divesEdited signal sends the changed field as a parameter.
Since some undo-commands change multiple fields, this led to
numerous signals for a single command. This in turn would lead
to multiple profile-reloads and statistic recalculations.
Therefore, turn the enum into a bitfield. For simplicity,
provide a constructor that takes classical flags and turns
them into the bitfield. This is necessary because C-style
named initialization is only supported on C++20 onward!
Is this somewhat overengineered? Yes, maybe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On undo/redo, the dive statistics tab was not updated even
if a selected dive was changed. Fix that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of copying the displayed dive, generate an undo command.
This makes the replanning an undoable action and fixes a bug
where the dive details have not been updated correctly.
Fixes#2280
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement an undo command that overwrites the dive-computers and
cylinders of the current dive with a given dive. This will be used
when replanning a dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The undo system sets updates individual dive fields on
redo respectively undo. Make salinity such a field, since
it is changed on replanning a dive.
To do this, break out the "update salinity" functionality
into its own function, add an entry to the DiveField enum
and add the corresponding switch-case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive-computer freeing code was local to dive.c. Implementing
the replan undo-command will need that functionality. Therefore,
export it as a global function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I'm a bit confused why this enum has two extra values, NUM_DIVEMODE and
UNDEF_COMP_TYPE. I can see how this could create confusion. This may
benefit from addition review.
Found by Coverity. Fixes CID 350092.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I am at a loss for words. Especially as we didn't need those quotes in
the first place. What was I thinking?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
At least in one of the logs we saw there seemed to be trailing spaces.
It should be enough for the BT name to start with "Mares Genius" in
order to be recognized.
Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should fix the odd double builds for people who create branches for
pull requests in the main repository.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This means that PRs from people using the main repo for their staging
branches will get both transfer.sh and a release.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I wonder if this will cause issues where the actions sometimes run
twice. But we'll deal with that rather than dealing with not having the
tests on pull requests.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't have the "show all dive computers" logic on mobile, so we need
something like this.
Possibly we should use the libdivecomputer matching code if it exists,
but that's a much bigger change, let's do this incremental one for now.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The edit description wasn't detailed enough to need changing, but I
noticed a reference to behavior that we have disabled.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a couple more roles and remove the dive role that allows accesss to
the DiveObjectHelper in the first place.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>