From 7180c708e9cd8de3ebb5e281fe2709a027624cee Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 7 Oct 2013 22:37:32 -0700 Subject: Fix some signedness issues I always worry if these are worth following up on - but these seem pretty clear and obvious to me. As far as the planner is concerned, depth is unsigned. Signed-off-by: Dirk Hohndel --- deco.c | 2 +- dive.h | 2 +- planner.c | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/deco.c b/deco.c index 788c258fe..baa727c89 100644 --- a/deco.c +++ b/deco.c @@ -23,7 +23,7 @@ struct buehlmann_config { double satmult; //! safety at inert gas accumulation as percentage of effect (more than 100). double desatmult; //! safety at inert gas depletion as percentage of effect (less than 100). - int last_deco_stop_in_mtr; //! depth of last_deco_stop. + unsigned int last_deco_stop_in_mtr; //! depth of last_deco_stop. double gf_high; //! gradient factor high (at surface). double gf_low; //! gradient factor low (at bottom/start of deco calculation). double gf_low_position_min; //! gf_low_position below surface_min_shallow. diff --git a/dive.h b/dive.h index 98cae9c38..d466643d2 100644 --- a/dive.h +++ b/dive.h @@ -692,7 +692,7 @@ extern double restore_deco_state(char *data); struct divedatapoint { int time; - int depth; + unsigned int depth; int o2; int he; int po2; diff --git a/planner.c b/planner.c index 8fb49d45a..ec00bda27 100644 --- a/planner.c +++ b/planner.c @@ -12,12 +12,12 @@ #include "planner.h" #include "gettext.h" -int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000, - 30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000, - 60000, 63000, 66000, 69000, 72000, 75000, 78000, 81000, 84000, 87000, - 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, - 180000, 190000, 200000, 220000, 240000, 260000, 280000, 300000, - 320000, 340000, 360000, 380000 +unsigned int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000, + 30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000, + 60000, 63000, 66000, 69000, 72000, 75000, 78000, 81000, 84000, 87000, + 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, + 180000, 190000, 200000, 220000, 240000, 260000, 280000, 300000, + 320000, 340000, 360000, 380000 }; double plangflow, plangfhigh; char *disclaimer; @@ -146,7 +146,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, const char **error_ } /* how many seconds until we can ascend to the next stop? */ -int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p, const char **error_string_p) +static int time_at_last_depth(struct dive *dive, int o2, int he, unsigned int next_stop, char **cached_data_p, const char **error_string_p) { int depth, gasidx; double surface_pressure, tissue_tolerance; @@ -360,7 +360,7 @@ struct divedatapoint * plan_add_segment(struct diveplan *diveplan, int duration, } struct gaschanges { - int depth; + unsigned int depth; int gasidx; }; @@ -405,11 +405,11 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, struct dive } /* sort all the stops into one ordered list */ -static int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr) +static unsigned int *sort_stops(unsigned int *dstops, int dnr, struct gaschanges *gstops, int gnr) { int i, gi, di; int total = dnr + gnr; - int *stoplevels = malloc(total * sizeof(int)); + unsigned int *stoplevels = malloc(total * sizeof(int)); /* no gaschanges */ if (gnr == 0) { @@ -560,12 +560,12 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b struct dive *dive; struct sample *sample; int wait_time, o2, he, po2; - int ceiling, depth, transitiontime; - int stopidx, gi; + int transitiontime, gi; + unsigned int stopidx, depth, ceiling; double tissue_tolerance; struct gaschanges *gaschanges; int gaschangenr; - int *stoplevels; + unsigned int *stoplevels; set_gf(diveplan->gflow, diveplan->gfhigh); if (!diveplan->surface_pressure) -- cgit v1.2.3-70-g09d2