Commit graph

9277 commits

Author SHA1 Message Date
Lubomir I. Ivanov
ed98d3bc60 macos.c: update the default path retriaval
- added system_default_directory()
- both system_default_directory() and system_default_filename()
  now use the helper system_default_path_append()
- less safer compared to windows.c, assuming the OS is stricter on which
  environment variables exist!

[Dirk Hohndel: switched filename to be dynamically allocated to avoid
               possible buffer overflow]

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 16:04:10 +01:00
Lubomir I. Ivanov
6cddf1d720 windows.c: sanitize the backend for path retrieval
The old backend was less safe because, it didn't:
- support UTF-16 paths!
- use GetUserNameW()

The following changes were made:
- system_default_path_append() can be used to retrieve a path in the user
  Roaming path.
- system_default_directory() - this is equal to
  system_default_path_append(NULL)
- system_default_filename() also uses the helper
  system_default_path_append()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 15:43:21 +01:00
Rick Walsh
cd0963c26f TestPlan: update known Subsurface runtimes
The purpose of testing against known Subsurface runtimes is to warn (when test
is run in verbose mode) if the runtime has altered. Before the next release, we
should update the known Subsurface runtimes to match current behaviour, so we
are alerted when we change something during the next release cycle.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 15:18:48 +01:00
Rick Walsh
117d13485c TestPlan: include subsurfacestartup.h
Commit 9d8b0ad introduces the copy_prefs function, and uses it to replace prefs
= default_prefs. We need to include subsurfacestartup.h for it to work in
testplan.cpp, otherwise TestPlan_build fails.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 15:16:49 +01:00
Dirk Hohndel
4e4cd280c4 Add missing XML files for TestRenumber
Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 14:40:33 +01:00
Dirk Hohndel
9d8b0addf9 Correctly copy preferences
When just assigning one structure to the other we copy the string
pointers. If we then modify those strings in the copy, we happily free
the strings of the original. And then resetting the preferences equally
happily reused those strings, pointing to long since freed memory.

I think what I did now is excessive for the current use case in that it
copies a ton of strings that are unset in the default_prefs. But I figured
this is a rarely used function and I might as well do it correctly.

Also, once we implement multi user support with per user preferences we
will be copying completely populated preferences around (at least that's
my guess).

Fixes #940

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 10:19:43 +01:00
Dirk Hohndel
c75ec7a04a Detect if variables were not initialized
In print_files() it is possible that is_git_repository() actually doesn't
initialize remote and branch. Don't access them if they were not set up
correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 10:10:08 +01:00
Dirk Hohndel
2e6afb8e89 Correctly handle the webservice userid in preferences
Because of the way that the webservice userid can be saved both in the
preferences and in a data file it was treated differently than other
preferences settings - which prevented the reset of the preferences from
actually clearing it.

This patch makes sure that if the preferences are reset the preferences UI
reflects that. To make this work the data file loading functions can no
longer be allowed to just simply clear out the userid preference value
just in case they might load a new one.

Fixes #939

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 08:53:54 +01:00
Dirk Hohndel
e5fa424a67 Only check Windows version when building on Windows
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:23:22 +01:00
Guillaume GARDET
f07953ca00 Documentation: update french translation of user-manual
Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:03:00 +01:00
Dirk Hohndel
d567859e87 Show error messages during start up as soon as the main window is shown
When the user has setup cloud storage as their default file but didn't
store the cloud storage password an error is created but not shown until
another error happens - that's very confusing for the user.

This patch fixes that.

Fixes #938

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:30 +01:00
Dirk Hohndel
05f4f9b533 Cmake: ensure marbledata is actually copied into the build directory
This can be done regarless of whether Marble is enabled or not. No harm
done.

Fixes #937

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:30 +01:00
Dirk Hohndel
5861da0bce Remove unused part of the geocoding preferences
And always turn on geocoding. The user needs to trigger this manually
anyway, so there's no point in having the extra option in the preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:30 +01:00
Tomaz Canabrava
44762c4252 Do not use White font on newer Windows versions
It isn't readable with the very light background.
Which Windows versions this should be used on is a guess right now.
So far Windows 7 or newer, but that may need adjustment.

Fixes #935

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:30 +01:00
Tomaz Canabrava
437469e8ff Do not incorrectly use the UUID as the dive name
for some reason sometimes activating the dive via tab
or enter gave us the wrong column, so simply select the
right one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:30 +01:00
Dirk Hohndel
3c2965b151 Return the correct paths when is_git_repository() is called as dry_run
Otherwise we are creating the local git cache path with the remote
variable being uninitialized - which can cause crashes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:29 +01:00
Dirk Hohndel
c50fc04a82 Reset some more values in split_dive_at()
Otherwise fixup_dive() won't update them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:29 +01:00
Giorgio Marzano
c6eb747d0d Fix wrong max depth value in split dives
Signed-off-by: Giorgio Marzano <marzano.giorgio@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:29 +01:00
Dirk Hohndel
c378df81ab Mark divelist as changed even if imported dives got merged
The number of dives didn't go up, but we have one (or more) additional
dive computers added to an existing dive.

Fixes #936

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 00:01:09 +01:00
Dirk Hohndel
cb112f9ac5 Add test for import, merge and renumbering
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-05 16:35:09 +01:00
Dirk Hohndel
f0a176149a Don't use the numerus version of tr()
It looks like our tools create a .ts stance that transifex can't deal
with.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-05 16:35:09 +01:00
Dirk Hohndel
021af81443 With no filename set pick reasonable directory for Save as
If the user has no default filename set and starts Subsurface without a
filename, the directory that is opened with Save as ends up being the
current working directory of the executable, which might be its
installation directory - which in general is not a good place to save data
files to.

With this change we pick the directory which is usually used for the
default file, which should give us reasonable places on all OSs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-05 16:35:08 +01:00
Salvador Cuñat
1719a7f59e Update spanish translation of user manual to english b74809b
Changes to Bluetooth download section.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 19:03:44 +01:00
Dirk Hohndel
ae8d6341ae Updated texts and translations
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 16:42:27 +01:00
Anton Lundin
331a340780 Correct sign on Divesoft Freedom timestamps
I managed somehow to miss-read and by accident told Linus that the
timestamp was signed.

It is a unsigned uint32_t, so this corrects the mistake i tricked Linus
into making.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 16:29:35 +01:00
Sander Kleijwegt
a02ea68582 HTML Export: Ignore case when searching for tags
Fixes #934

Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 16:29:32 +01:00
Robert C. Helling
a241393e7b Print paths to internal files in verbose mode
When run with -v option, this prints local file names like the path
to the local git repository and the hash file.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 16:29:31 +01:00
Dirk Hohndel
3f900885df Adjust expected output for TestParse
With commit b26e516e2a ("Dive_sites-Notes shouldn't be stored as
attribute") our output format changed slightly. Adjust the expected output
to match that change to ensure that TestParse passes again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 13:53:29 +01:00
Dirk Hohndel
a4a4276ed6 Make TestGitStorage run last
This can take a long time on slow connections so it makes sense to run all
the other tests first.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 13:52:31 +01:00
Rick Walsh
936bd52a42 VPM-B: Adjust Subsurface conservatism
Reverting commit 3d8e5b638a makes the CVA
calculation marginally less conservative, and one of the tests fails as a
result.  This tiny adjustment to the conservatism fixes that.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 13:45:37 +01:00
Rick Walsh
26cab60518 Revert "VPM-B restore deco state before calculating next gradient"
This reverts commit 3d8e5b638a.

Calculating the next gradient should be based on the tissue loading at the end
of the previous iteration, so it was wrong to restore the deco state first.
This has a tiny affect on the calculated profile, and makes one of the tests
fail.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 13:45:32 +01:00
Salvador Cuñat
b26e516e2a Dive_sites-Notes shouldn't be stored as attribute
If so, some formatting chars (like "\n") will be dropped while parsing.
This could be pretty annoying for a user who tries to keep notes other
than a simple text, e.g. if the site is a wreck, may be interesting to
have some data shown like:
			...
		Max. Depth =  60 m
		Min. Depth =  40 m
		Prow: bla, bla, bla.
		Stern: bla, bla, bla.
			...
instead of a single text line.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
ACKed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 12:35:51 +01:00
Dirk Hohndel
bdaa4eb8b0 Update README and ReleaseNotes for Beta 3
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 12:34:17 +01:00
Dirk Hohndel
a39038a902 In free dive mode split dives with only a 10 second surface interval
If the dive computer tells us that this was free diving we should be a lot
more aggressive splitting dives. For scuba dives a minute seems more
reasonable (to avoid splitting dives when you pop to the surface to get
the bearing and continue the dive after a few second).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 12:13:10 +01:00
Dirk Hohndel
76b31aa76a Don't use the same variable name for loop and temp storage
Oops. Moving the check to the beginning of the function in order to avoid
partial execution in commit 69036a1bb7 ("Avoid resource leak by bailing
early") had a nasty side effect. Since Linus used 'i' both to hold the
dive number and as a loop variable, by moving this to the top of the
function the dive nr was overwritten which caused all kinds of problems.

My bad - but of course you shouldn't mix loop variables with meaningful
variables, either...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 12:05:28 +01:00
Linus Torvalds
769365b4db Clean up Divesoft Freedome time parsing
So Anton Lundin says that the 32-bit timestamp for the Divesoft Freedom
is indeed a signed offset from Jan 1, 2000.

This does that, but also extracts the whole thing into a helper function
and makes sure that there are no overflows at any point by using
"timestamp_t" in the whole series, and all the operations are "obviously
safe" in their types (ie no "unsigned char gets widened to 'int' and
then we shift it left by 24 bits").

Signed-off-by: Linus Torvalds <torvalds@linux-fundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 10:41:03 -04:00
Dirk Hohndel
08db242e0e Avoid ignoring file read errors
This fixes a bunch of Coverity warnings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 10:02:55 -04:00
Dirk Hohndel
58fbee7150 Make logical block match indentation
Coverity CID 1325519

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 09:47:37 -04:00
Dirk Hohndel
69036a1bb7 Avoid resource leak by bailing early
While in the current use this won't happen, if someone were to call
split_dive_at with a dive that's not in the dive_table, let's bail right
away before doing any work.

Coverity CID 1325517 1325518

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 09:44:16 -04:00
Dirk Hohndel
b2fcc7c813 Don't keep all the split dives invisibly selected
While the visual state didn't show it, our internal tracking of the
selected state was copied causing all kinds of unexpected behavior. With
this commit we get this right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 07:25:52 -04:00
Dirk Hohndel
f8e9c975b7 Use copy_string() to avoid potential crash
If the trip has no location or notes calling strdup on NULL is just a bad
idea.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 07:19:55 -04:00
Dirk Hohndel
c30dfba433 Don't delete the trip when splitting the only dive in a trip
When splitting dives make sure the new dives first are part of the same
trip the original dive was in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 07:17:29 -04:00
Linus Torvalds
e964f533ff Fix 32-bit overflow in Divesoft Freedom time handling
Commit 31fb2e4c62 ("Avoid possible sign extension") handled the
problem when a "unsigned char" is shifted 24 bits left, and becomes a
"signed int".  By casting the result to uint32_t, that signed case won't
happen.

However, there were two bugs in that fix.

The first is the comment.  It's not that "timestamp_t" is signed that is
the problem.  No, the problem is inherent in the C expression

    (ptr[11] << 24)

where "ptr[11]" is an unsigned char.  In C arithmetic, unsigned char is
implicitly type-expanded to "int", so while it has a value between
0..255, when you shift it left by 24, you can get a *negative* "int" as
a result.

So it's actually "ptr[11]" that should have been cast to "unsigned", but
it so happens that you can do all the shifting and adding in "int", and
then cast the end result to "uint32_t" and you'll get the same value.
But at no point did "timestamp_t" matter.

The other bug was pre-existing and just not fixed.  When the code does
the "+ 946684800" (to turn the timestamp to be seconds from the start of
2000, into seconds since the "unix epoch", ie 1970) that arithmetic is
now done in that "uint32_t" (and used to be done in "int").

Which means that the addition can overflow in 32 bits *before* it is
cast to timestamp_t (which is 64 bits).

Admittedly that 32-bit overflow happens a bit later than the sign bit
gets set, but if we're worried aboout overflows, let's just do this
right.

In other words, we have a 32-bit unsigned offset since Jan 1, 2000, and
for the full range we need to do the epoch correction in 32 bits.
Because otherwise you fail in the year 2106 (32-bit unsigned unix epoch
time limit), even though the 32-bit seconds *should* work all the way
until the year 2136.

Of course, I'll be rather surprised if people still use the Divesoft
Freedom in the year 2106.  Or rather, I won't be surprised, because I'll
be dead.

But if we think that the signed problem matters (in the year 2068), then
dammit, we can extend it another 30 years.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 00:05:40 -04:00
Dirk Hohndel
7cfd124f67 Avoid negative array index
This case should be impossible to hit - but this seems better than
assuming this can never happen.

Coverity CID 1325458

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 21:25:17 -04:00
Dirk Hohndel
ae854ff822 Remove pointless assignment
In every code path stopping is overwritten before it is ever accessed.

Coverity CID 1325278

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 17:41:02 -04:00
Dirk Hohndel
d9bbb97bd0 Avoid working with invalid dive indices
When calling merge_two_dives both dives should be in the dive list so i
and j should never be -1. But just as extra precaution, bail if that's the
case (so that the helper functions below aren't called with negative
indices).

Coverity CID 1189514

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 17:36:23 -04:00
Dirk Hohndel
6b9aea1b96 Remove unused member
This isn't the bug that Coverity showed, but it was found by looking at
CID 1307969

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 17:30:21 -04:00
Dirk Hohndel
31fb2e4c62 Avoid possible sign extension
Interesting theoretical bug (it'll be a while before we run into this
one).

Coverity CID 1307979

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 15:48:50 -04:00
Dirk Hohndel
6b0d9adb61 Avoid potential uninitialized access
I don't think this could ever happen but hey, let's be sure.

Coverity CID 1307985

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 15:42:43 -04:00
Dirk Hohndel
f09a3c3304 Avoid potentially uninitialized member
This seems a false positive, reply is always set before it is used, but
there's no harm in setting it explicitly.

Coverity CID 1325280

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-02 15:25:03 -04:00