diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-20 06:37:19 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-20 06:37:19 +0900 |
commit | 09e7c61feeeabac3dd983c11aca49b23155fff80 (patch) | |
tree | f82b271b89dd0f2f85cc78a1c0724df29204f439 /statistics.c | |
parent | b303f217a9d66ef031c58534b3796ddefbe362c5 (diff) | |
download | subsurface-09e7c61feeeabac3dd983c11aca49b23155fff80.tar.gz |
Consistently use for_each_dive (and use it correctly)
The way the macro is written there is no need to test the dive against
NULL before dereferencing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/statistics.c b/statistics.c index 2a96efb81..feb812766 100644 --- a/statistics.c +++ b/statistics.c @@ -131,8 +131,7 @@ void process_all_dives(struct dive *dive, struct dive **prev_dive) /* this relies on the fact that the dives in the dive_table * are in chronological order */ - for (idx = 0; idx < dive_table.nr; idx++) { - dp = dive_table.dives[idx]; + for_each_dive (idx, dp) { if (dive && dp->when == dive->when) { /* that's the one we are showing */ if (idx > 0) @@ -230,10 +229,10 @@ static void get_ranges(char *buffer, int size) { int i, len; int first = -1, last = -1; + struct dive *dive; snprintf(buffer, size, "%s", translate("gettextFromC", "for dives #")); - for (i = 0; i < dive_table.nr; i++) { - struct dive *dive = get_dive(i); + for_each_dive (i, dive) { if (!dive->selected) continue; if (dive->number < 1) { |