aboutsummaryrefslogtreecommitdiffstats
path: root/core/import-shearwater.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-04 18:59:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-09 19:19:04 +0100
commit8df3705152aa32d8551b5fb7db08e0c8e442b480 (patch)
tree60879e7d4af85d71d64885ea903ac234a09bffda /core/import-shearwater.c
parent7c9f46acd202121e67557bb634961ef17a9f6c1f (diff)
downloadsubsurface-8df3705152aa32d8551b5fb7db08e0c8e442b480.tar.gz
Cleanup: return cylinder from cylinder_start() in parser
Most callers of this function accessed the newly generated cylinder immediately after calling this function. Thus, for convenience, return the added cylinder. This avoids a number of verbose expressions. On the flip side, cylinder_start() now has to be cast to function returning void in a the "nesting" function table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/import-shearwater.c')
-rw-r--r--core/import-shearwater.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/core/import-shearwater.c b/core/import-shearwater.c
index cd5815c6e..1c1e68eb4 100644
--- a/core/import-shearwater.c
+++ b/core/import-shearwater.c
@@ -28,8 +28,7 @@ static int shearwater_cylinders(void *param, int columns, char **data, char **co
if (o2 == 990 && he == 0)
o2 = 1000;
- cylinder_start(state);
- cyl = &state->cur_dive->cylinders.cylinders[state->cur_dive->cylinders.nr - 1];
+ cyl = cylinder_start(state);
cyl->gasmix.o2.permille = o2;
cyl->gasmix.he.permille = he;
cylinder_end(state);
@@ -70,8 +69,7 @@ static int shearwater_changes(void *param, int columns, char **data, char **colu
}
if (!found) {
// Cylinder not found, creating a new one
- cylinder_start(state);
- cyl = &state->cur_dive->cylinders.cylinders[state->cur_dive->cylinders.nr - 1];
+ cyl = cylinder_start(state);
cyl->gasmix.o2.permille = o2;
cyl->gasmix.he.permille = he;
cylinder_end(state);