From 20b348579bc206231d81f8c5fd256e656c8409e4 Mon Sep 17 00:00:00 2001 From: Salvador Cuñat Date: Thu, 16 Mar 2017 16:55:40 +0100 Subject: smtk-import rework smtk_build_tank_info() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cylinder info is built one by one. This way, instead of passing dive and tank number parameters, just passing a pointer to the tank been worked seems preferable. It also introduces lrint() in the function to round the doubles values obtained from libmdb for tank size and workingpressure. Signed-off-by: Salvador Cuñat --- smtk-import/smartrak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'smtk-import') diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index 2e50baf0a..789955654 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -396,7 +396,7 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, timestamp_t when, uin free(str); } -static void smtk_build_tank_info(MdbHandle *mdb, struct dive *dive, int tanknum, char *idx) +static void smtk_build_tank_info(MdbHandle *mdb, cylinder_t *tank, char *idx) { MdbTableDef *table; MdbColumn *col[MDB_MAX_COLS]; @@ -409,9 +409,9 @@ static void smtk_build_tank_info(MdbHandle *mdb, struct dive *dive, int tanknum, for (i = 1; i <= atoi(idx); i++) mdb_fetch_row(table); - dive->cylinder[tanknum].type.description = copy_string(col[1]->bind_ptr); - dive->cylinder[tanknum].type.size.mliter = strtod(col[2]->bind_ptr, NULL) * 1000; - dive->cylinder[tanknum].type.workingpressure.mbar = strtod(col[4]->bind_ptr, NULL) * 1000; + tank->type.description = copy_string(col[1]->bind_ptr); + tank->type.size.mliter = lrint(strtod(col[2]->bind_ptr, NULL) * 1000); + tank->type.workingpressure.mbar = lrint(strtod(col[4]->bind_ptr, NULL) * 1000); smtk_free(bound_values, table->num_cols); mdb_free_tabledef(table); -- cgit v1.2.3-70-g09d2