mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Fix some of the gcc-4.8 warnings
Most of the warnings are IMHO false positives: e.g.: an enum variable is initialized in a switch statement that has a case for each possible enum value - yet gcc 4.8 warns that it could be used uninitialized; or: two variables are initialized together in the code - second one of them is previously initialized to -1 at declaration time, both are initialized in an if (second one == -1) clause - so they are guaranteed to both be initialized... I did not "fix" those as the code is actually correct. But there are three spots where it catches things that could indeed go wrong (with odd input data in one of them). This commit also adds a check to only call g_type_init() for older versions of glib as in newer ones it is deprecated. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1d02ba12a3
commit
4cf244e228
4 changed files with 7 additions and 4 deletions
|
@ -1889,8 +1889,9 @@ void init_ui(int *argcp, char ***argvp)
|
|||
star_strings[4] = "**** ";
|
||||
star_strings[5] = "*****";
|
||||
}
|
||||
#if !GLIB_CHECK_VERSION(2,3,6)
|
||||
g_type_init();
|
||||
|
||||
#endif
|
||||
subsurface_open_conf();
|
||||
|
||||
load_preferences();
|
||||
|
|
|
@ -668,6 +668,7 @@ static void get_ranges(char *buffer, int size)
|
|||
}
|
||||
}
|
||||
}
|
||||
len = strlen(buffer);
|
||||
if (first != last) {
|
||||
if (first + 1 == last)
|
||||
snprintf(buffer + len, size - len, ", %d", last);
|
||||
|
|
|
@ -546,7 +546,7 @@ static void parse_divespot(char *buf)
|
|||
char *tag, *type, *val;
|
||||
char locationstring[1024] = "";
|
||||
int divespot, len;
|
||||
double latitude, longitude;
|
||||
double latitude = 0.0, longitude = 0.0;
|
||||
|
||||
|
||||
if (strcmp(tp, "divespot"))
|
||||
|
|
5
uemis.c
5
uemis.c
|
@ -288,7 +288,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
|
|||
int datalen;
|
||||
int i;
|
||||
uint8_t *data;
|
||||
struct sample *sample;
|
||||
struct sample *sample = NULL;
|
||||
uemis_sample_t *u_sample;
|
||||
struct dive *dive = datap;
|
||||
struct divecomputer *dc = &dive->dc;
|
||||
|
@ -365,6 +365,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
|
|||
i += 0x25;
|
||||
u_sample++;
|
||||
}
|
||||
dive->dc.duration.seconds = sample->time.seconds - 1;
|
||||
if (sample)
|
||||
dive->dc.duration.seconds = sample->time.seconds - 1;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue