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>
No point in slurping in all of dive.h for translation units that only
want to do some time manipulation without ever touching a dive.
Don't call the header "time.h", because we don't want to end up in a
confusion with the system header of the same name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I would have bet money that Android used to send stderr to the logcat
log, but apparently it doesn't (anymore?). So in order to be able to
have a chance to debug weird cloud storage issues on Android, let's do
some wholesale replacement of fprintf(stderr,...) with our own version
of the INFO macro that we long ago borrowed from libdivecomputer (and
rename it to ensure we don't have a conflict there).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In the QML code we pass ids around. I had assumed that there already was a reverse
lookup function, but I wasn't able to find it. So I added it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we now have a selection.c translation unit, put the selection-
related functions there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make it easier to pass around trips through QML, give each trip
a unique id. The id is generated in alloc_trip() and uses the same
function to generate unique dive ids.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When checking for trip-overlap on import, only really overlapping trips
have been considered, i.e. when dives had overlapping times.
Instead use the TRIP_THRESHOLD so that on download dives are added to
the same trip if in a two-days time frame.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>