diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-11-05 15:58:24 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-11-13 20:50:10 -0800 |
commit | adbc71f9daf6778cf7402a18f9d954226bfceda4 (patch) | |
tree | 775ed19cf46165a707a5b69393fdabf37d3a939f /core | |
parent | 1f8506ce645000bd158fcd3b2c9c799505c78bb2 (diff) | |
download | subsurface-adbc71f9daf6778cf7402a18f9d954226bfceda4.tar.gz |
Init every struct sample with default values
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core')
-rw-r--r-- | core/device.c | 5 | ||||
-rw-r--r-- | core/dive.c | 4 | ||||
-rw-r--r-- | core/save-git.c | 2 | ||||
-rw-r--r-- | core/save-xml.c | 2 |
4 files changed, 9 insertions, 4 deletions
diff --git a/core/device.c b/core/device.c index 25c5136a9..d5e723765 100644 --- a/core/device.c +++ b/core/device.c @@ -114,6 +114,7 @@ struct divecomputer *fake_dc(struct divecomputer *dc, bool alloc) static struct sample fake_samples[6]; static struct divecomputer fakedc; struct sample *fake = fake_samples; + int i; fakedc = (*dc); if (alloc) @@ -129,6 +130,10 @@ struct divecomputer *fake_dc(struct divecomputer *dc, bool alloc) memset(fake, 0, sizeof(fake_samples)); fake[5].time.seconds = max_t; + for (i = 0; i < 6; i++) { + fake_samples[i].bearing.degrees = -1; + fake_samples[i].ndl.seconds = -1; + } if (!max_t || !max_d) return &fakedc; diff --git a/core/dive.c b/core/dive.c index 9e3d42a44..7cad36154 100644 --- a/core/dive.c +++ b/core/dive.c @@ -1727,7 +1727,7 @@ static void merge_one_sample(struct sample *sample, int time, struct divecompute { int last = dc->samples - 1; if (last >= 0) { - static struct sample surface; + static struct sample surface = { .bearing.degrees = -1, .ndl.seconds = -1 }; struct sample *prev = dc->sample + last; int last_time = prev->time.seconds; int last_depth = prev->depth.mm; @@ -1772,7 +1772,7 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru for (;;) { int at, bt; - struct sample sample; + struct sample sample = { .bearing.degrees = -1, .ndl.seconds = -1 }; if (!res) return; diff --git a/core/save-git.c b/core/save-git.c index 6496d28ad..7d7c8d9d2 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -350,7 +350,7 @@ static void save_samples(struct membuffer *b, struct dive *dive, struct divecomp int nr; int o2sensor; struct sample *s; - struct sample dummy = {}; + struct sample dummy = { .bearing.degrees = -1, .ndl.seconds = -1 }; /* Is this a CCR dive with the old-style "o2pressure" sensor? */ o2sensor = legacy_format_o2pressures(dive, dc); diff --git a/core/save-xml.c b/core/save-xml.c index 5bc4f5b38..fe1d73817 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -364,7 +364,7 @@ static void save_samples(struct membuffer *b, struct dive *dive, struct divecomp int nr; int o2sensor; struct sample *s; - struct sample dummy = {}; + struct sample dummy = { .bearing.degrees = -1, .ndl.seconds = -1 }; /* Set up default pressure sensor indexes */ o2sensor = legacy_format_o2pressures(dive, dc); |