Realistically this is a false positive as we should never use a second
BTDiscovery instance - but there's nothing wrong with being extra certain.
Coverity CID 208319
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous attempt to fix this in commit 652e382e68 ("Cleanup: avoid a
few memory leaks") was clearly bogus. Oops.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we cannot store tanks / gases past MAX_CYLINDERS (currently 20),
there is no point in analyzing those data.
Coverity CID 208339
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A very very trival fix, for a mysterious issue. When loading
GPS fix data from the server, the string date was parsed with
the format "yyy-M-d". And no, the "yyy" is no typo here, but
was the reason that data from the read from server got a
1/1/1970 data. And when a user decided to upload that data
to the server again, we ended up with 2 copies of the
GPS fix. One with correct data (as originally saved), and
one new with the bogus date.
In order to het rid of those weird 1/1/1970 GPS fixes, users
will have to remove them by hand.
Fixes: #567
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
For deep dives with long deco, the sum of deco stops could
overflow. This is prevent by turning it into long.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
There was a curious pattern of singletons being implemented based on
QScopedPointer<>s. This is an unnecessary level of indirection:
The lifetime of the smart pointer is the same as that of the
pointed-to object. Therefore, replace these pointers by the respective
objects.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The two final newlines in the help message were removed in commit
0c74f7a2c8.
Re-add them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To access a QMap<> entry, the value() function is used with a sentinel
as default value. If the sentinel is returned, the code assumes that
the searched for entry doesn't exist.
Make this code more idiomatic by using an iterator and testing for
end().
This fixes a compiler warning, because only one of the elements of
the sentinel was initialized, but the remaining elements were
copied. Harmless, because the code would exit early if it found
the sentinel. Still not nice.
While redoing this function, the entry-not-found message was improved
(adding of function name, space between massage and timestamp) and
elevated from debug to warning level.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
plot_info->nr should always be > 0. If this is not the case, write a
message to stderr instead of crashing in add_plot_pressure(). This
silences an use-of-uninitialized-variable warning.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
last_ceiling was used before initialization in the first iteration
of the loop in calculate_deco_information().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since the corresponding error message appears thrice, it is translated
once at the beginning of the function (even in the non-error case).
A single-byte fread() was transformed into getc().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A small redo of 78bafe8f62. The quotes cause the original
functionality not to work. Ignore them as well.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Unfortunately, in my commit 48d9c8eb6e, I fixed only half of
the problems related to the functionality introduced by Stefan in
commit 46004c39e2. The lonely m (that was fixed) caused
a parsing error, but forgotten where the single quotes around
the depth value. These quotes simply causes the new functionality
not to work. Again, the fix is simple: do not erroneously save
quotes. And as the new functionality is pretty obscure
(replanning a non-planned dive, and manually entering a gas switch
depth), another bug that could go unnoticed for years.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In hindsight a very simple bug to fix, but it requires some
knowledge on the inner workings of our git storage. The changes
on merge of dive sites were simply not saved (completely) because
the git storage code has a cache that we need to invalidate
selectively (ie. for the dive we just gave a new dive site uuid)
to get things finally embedded in the overall commit.
The main reason this bug went unnoticed for more than 2 years is
that most people use the XML/SSRF format (where this problem is
non exsistent), and dive site merging is probably not a very
much used feature either.
Fixes: #939
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A bogus key/value pair was introduced in the cylinder,
consisting of a lonely "m" without value. This is caused
by commit 46004c39e2 and fixed in 48d9c8eb6e. See referenced
commits for more info.
Just ignore this key/value pair. No processing is broken
due to this, as the git storage stores only metric SI type data.
In fact, the m unit is superfluous anyway.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In a session with the profile I saw that the planner spends
a lot of time waiting to obtain the lock for the factor cache.
Most of the time we are only reading that cache and that
is save to do in parallel (according to the Qt IRC channel).
So we can use a QReadWriteLock instead of a QMutex. This
appears to be quite a performance boost, in particular
for VPM-B
Signed-off-by: Robert C. Helling <helling@atdotde.de>
I never realized that my hashes weren't written, because it only
outputs a debug instead of a warning message.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 46004c39e2 introduces a new field in the logbook outputs
(depth of a cylinder). While in XML the depth unit is stored with a space
between value and unit (m), in our git storage, the unit m is without
space. As the git storage parser uses a space to separate individual
key/value pairs, the erroneously saved space results in parsing warnings
when opening the logbook.
The unwanted space is normally saved just after download of a new dive
from the dive computers, so all desktop-git-storage uses are affected,
and more worrying, mobile beta users.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Internal floating point (FP) calculations should be performed using double
unless there is a very good reason. This avoids headaches with conversions.
Indeed, the vast majority of FP calculations were already done using double.
This patch adapts most remaining calculations. Not converted where things
that were based on binary representations and variables which weren't used
anyway.
An analysis of all instances follows:
core/plannernotes.c, l.404:
This was a comparison between two floats. On the left side, first an integer
was cast to float then multiplied with and integer and divided by a constant
double. The right hand side was an integer cast to a float. Simply divide by
1000.0 first to convert to double and continue with calculations. On the right
hand side, remove the cast, because the integer will be implicitely cast to
double for comparison. This conversion actually emits less instructions,
because no conversion to double and back is performed.
core/planner.c, l.613:
Same analysis as previous case.
subsurface-desktop-main.cpp, l.155:
A local variable representing the version OpenGL version. Turn this into
integer logic. Not only does this avoid dreaded FP rounding issues, it also
works correctly for minor version > 10 (not that such a thing is to be
expected anytime soon).
abstractpreferenceswidget.[h/cpp]:
A widget where the position is described as a float. Turn into double.
desktop-widgets/divelogexportdialog.cpp, l.313:
total_weight is described as float. Use double arithmetics instead. This
instance fixes a truncation warning emitted by gcc.
The function isCloudUrl() was only called in one place, parse_file().
But, isCloudUrl() could only return true if the filename was of the
git-repository kind (url[branch]). In such a case, control flow would
never reach the point where isCloudUrl() is called, since
is_git_repository() returns non-NULL and the function returns early.
Therefore, remove this function. Moreover, adapt the affected if-statement
by replacing "str && !strcmp(str, ...)" with the more concise
"same_string(str, ...)".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
See 2182167b53. Keep the dupicated code in sync.
Originally-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
See commit 6f42ab46da. Unfortunately, this code is duplicated
(and an obvious candidate for code cleanup). So replicate the mentioned
commit here. In fact, the mentioned issue #666 talkes about the mobile
app, and the fix was only done for the desktop.
Originally-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In libdivecomputer, a new divemode is added (DC_DIVEMODE_SCR) useful
for dive computers that have specfic functionality for semi-closed
rebreathers. At this moment, only the HW computers seem to provide
this.
This commit takes care of proper recognition of this new divemode
when importing data from a dive computer.
Tested on an actual import from an OSTC3 that contained
dives in this new mode.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This is just code cleanup. Jef renamed the CCR divemode constant
in libdivecomputer, but added a define to be backward compatible as
as well (so this rename did not break our Subsurface build).
Obviously, this breaks the build for people that build against an older
libdivecomputer, but I see no reason to do that.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This gets us the first merge with the upstream iostream implementation.
This requires a small change for serial_ftdi.c to build.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>