From 9c48130d3717ca7e569bcf36fe753c90cc9dc3ea Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 21 Sep 2019 13:41:45 +0200 Subject: [PATCH] Cleanup: replace is_dive_site_used() by is_dive_site_selected() is_dive_site_used() had a "selected" parameter. If true it would return whether the given dive site had a selected dive. Turns out all callers had this parameter set to true. Therefore, replace by a simplified function without the "selected" parameter and give the function an appropriate name. Signed-off-by: Berthold Stoeger --- core/divesite.c | 5 +---- core/divesite.h | 2 +- core/save-xml.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/divesite.c b/core/divesite.c index db5d87cdf..68ac6e98a 100644 --- a/core/divesite.c +++ b/core/divesite.c @@ -191,13 +191,10 @@ int nr_of_dives_at_dive_site(struct dive_site *ds) return ds->dives.nr; } -bool is_dive_site_used(struct dive_site *ds, bool select_only) +bool is_dive_site_selected(struct dive_site *ds) { int i; - if (!select_only) - return ds->dives.nr > 0; - for (i = 0; i < ds->dives.nr; i++) { if (ds->dives.dives[i]->selected) return true; diff --git a/core/divesite.h b/core/divesite.h index 433ad056e..2dc64f81e 100644 --- a/core/divesite.h +++ b/core/divesite.h @@ -51,7 +51,7 @@ int add_dive_site_to_table(struct dive_site *ds, struct dive_site_table *ds_tabl struct dive_site *alloc_or_get_dive_site(uint32_t uuid, struct dive_site_table *ds_table); struct dive_site *alloc_dive_site(); int nr_of_dives_at_dive_site(struct dive_site *ds); -bool is_dive_site_used(struct dive_site *ds, bool select_only); +bool is_dive_site_selected(struct dive_site *ds); void free_dive_site(struct dive_site *ds); int unregister_dive_site(struct dive_site *ds); int register_dive_site(struct dive_site *ds); diff --git a/core/save-xml.c b/core/save-xml.c index 912350da2..c2e9828d1 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -608,7 +608,7 @@ static void save_dives_buffer(struct membuffer *b, const bool select_only, bool if (dive_site_is_empty(ds)) continue; /* Only write used dive sites when exporting selected dives */ - if (select_only && !is_dive_site_used(ds, true)) + if (select_only && !is_dive_site_selected(ds)) continue; put_format(b, "uuid); @@ -823,7 +823,7 @@ static void save_dive_sites_buffer(struct membuffer *b, const bool select_only, if (dive_site_is_empty(ds)) continue; /* Only write used dive sites when exporting selected dives */ - if (select_only && !is_dive_site_used(ds, true)) + if (select_only && !is_dive_site_selected(ds)) continue; put_format(b, "uuid);