mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: remove count_divecomputers() function
There is a number_of_computers() function which does the same thing with two exceptions: 1) checks for null-dive 2) returns an unsigned int Replace calls to count_divecomputers() by calls to number_of_computers(). In one case, the return type makes a different - add a cast to int there. Ultimately, we should probably change the dc_number to signed int throughout the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0424ee8996
commit
048cdcaa31
4 changed files with 4 additions and 16 deletions
13
core/dive.c
13
core/dive.c
|
@ -3535,17 +3535,6 @@ struct dive *make_first_dc(const struct dive *d, int dc_number)
|
|||
return res;
|
||||
}
|
||||
|
||||
int count_divecomputers(const struct dive *d)
|
||||
{
|
||||
int ret = 1;
|
||||
struct divecomputer *dc = d->dc.next;
|
||||
while (dc) {
|
||||
ret++;
|
||||
dc = dc->next;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void delete_divecomputer(struct dive *d, int num)
|
||||
{
|
||||
int i;
|
||||
|
@ -3574,7 +3563,7 @@ static void delete_divecomputer(struct dive *d, int num)
|
|||
|
||||
/* If this is the currently displayed dive, we might have to adjust
|
||||
* the currently displayed dive computer. */
|
||||
if (d == current_dive && dc_number >= count_divecomputers(d))
|
||||
if (d == current_dive && dc_number >= number_of_computers(d))
|
||||
dc_number--;
|
||||
invalidate_dive_cache(d);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue