mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b303f217a9
commit
09e7c61fee
5 changed files with 17 additions and 25 deletions
|
@ -270,10 +270,8 @@ void MainTab::enableEdition(EditMode newEditMode)
|
|||
|
||||
// We may be editing one or more dives here. backup everything.
|
||||
struct dive *mydive;
|
||||
for (int i = 0; i < dive_table.nr; i++) {
|
||||
mydive = get_dive(i);
|
||||
if (!mydive)
|
||||
continue;
|
||||
int i;
|
||||
for_each_dive(i, mydive) {
|
||||
if (!mydive->selected)
|
||||
continue;
|
||||
|
||||
|
@ -596,14 +594,12 @@ void MainTab::reload()
|
|||
#define EDIT_SELECTED_DIVES(WHAT) \
|
||||
do { \
|
||||
struct dive *mydive = NULL; \
|
||||
int _i; \
|
||||
if (editMode == NONE) \
|
||||
return; \
|
||||
\
|
||||
for (int _i = 0; _i < dive_table.nr; _i++) { \
|
||||
mydive = get_dive(_i); \
|
||||
if (!mydive || mydive == current_dive)\
|
||||
continue; \
|
||||
if (!mydive->selected) \
|
||||
for_each_dive (_i, mydive) { \
|
||||
if (!mydive->selected || mydive == current_dive) \
|
||||
continue; \
|
||||
\
|
||||
WHAT; \
|
||||
|
@ -836,10 +832,8 @@ void MainTab::rejectChanges()
|
|||
}
|
||||
|
||||
struct dive *mydive;
|
||||
for (int i = 0; i < dive_table.nr; i++) {
|
||||
mydive = get_dive(i);
|
||||
if (!mydive)
|
||||
continue;
|
||||
int i;
|
||||
for_each_dive (i, mydive) {
|
||||
if (!mydive->selected)
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue