diff options
Diffstat (limited to 'subsurface-core')
-rw-r--r-- | subsurface-core/dive.c | 21 | ||||
-rw-r--r-- | subsurface-core/dive.h | 8 | ||||
-rw-r--r-- | subsurface-core/units.h | 2 |
3 files changed, 17 insertions, 14 deletions
diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c index 083767582..47b3e1f06 100644 --- a/subsurface-core/dive.c +++ b/subsurface-core/dive.c @@ -58,7 +58,7 @@ int event_gasmix_redundant(struct event *ev) he == ev->gas.mix.he.permille; } -struct event *add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name) +struct event *add_event(struct divecomputer *dc, unsigned int time, int type, int flags, int value, const char *name) { int gas_index = -1; struct event *ev, **p; @@ -738,7 +738,8 @@ void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *me { int i; int depthtime[MAX_CYLINDERS] = { 0, }; - int lasttime = 0, lastdepth = 0; + uint32_t lasttime = 0; + int lastdepth = 0; int idx = 0; for (i = 0; i < MAX_CYLINDERS; i++) @@ -765,7 +766,7 @@ void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *me dc = fake_dc(dc, false); for (i = 0; i < dc->samples; i++) { struct sample *sample = dc->sample + i; - int time = sample->time.seconds; + uint32_t time = sample->time.seconds; int depth = sample->depth.mm; /* Make sure to move the event past 'lasttime' */ @@ -2619,7 +2620,8 @@ static struct divetag *taglist_add_divetag(struct tag_entry **tag_list, struct d struct divetag *taglist_add_tag(struct tag_entry **tag_list, const char *tag) { - int i = 0, is_default_tag = 0; + size_t i = 0; + int is_default_tag = 0; struct divetag *ret_tag, *new_tag; const char *translation; new_tag = malloc(sizeof(struct divetag)); @@ -2675,7 +2677,7 @@ static void taglist_merge(struct tag_entry **dst, struct tag_entry *src1, struct void taglist_init_global() { - int i; + size_t i; for (i = 0; i < sizeof(default_tags) / sizeof(char *); i++) taglist_add_tag(&g_tag_list, default_tags[i]); @@ -2920,7 +2922,8 @@ static void force_fixup_dive(struct dive *d) */ static int split_dive_at(struct dive *dive, int a, int b) { - int i, t, nr; + int i, nr; + uint32_t t; struct dive *d1, *d2; struct divecomputer *dc1, *dc2; struct event *event, **evp; @@ -3249,7 +3252,7 @@ void set_informational_units(char *units) } } -void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth) +void average_max_depth(struct diveplan *dive, unsigned int *avg_depth, unsigned int *max_depth) { int integral = 0; int last_time = 0; @@ -3415,7 +3418,7 @@ void make_first_dc() } /* always acts on the current dive */ -int count_divecomputers(void) +unsigned int count_divecomputers(void) { int ret = 1; struct divecomputer *dc = current_dive->dc.next; @@ -3455,7 +3458,7 @@ void delete_current_divecomputer(void) /* helper function to make it easier to work with our structures * we don't interpolate here, just use the value from the last sample up to that time */ -int get_depth_at_time(struct divecomputer *dc, int time) +int get_depth_at_time(struct divecomputer *dc, unsigned int time) { int depth = 0; if (dc && dc->sample) diff --git a/subsurface-core/dive.h b/subsurface-core/dive.h index f8970b237..f84d45c24 100644 --- a/subsurface-core/dive.h +++ b/subsurface-core/dive.h @@ -387,7 +387,7 @@ extern timestamp_t picture_get_timestamp(char *filename); extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic); extern int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc); -extern int get_depth_at_time(struct divecomputer *dc, int time); +extern int get_depth_at_time(struct divecomputer *dc, unsigned int time); static inline int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null) { @@ -567,7 +567,7 @@ static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr) extern timestamp_t dive_endtime(const struct dive *dive); extern void make_first_dc(void); -extern int count_divecomputers(void); +extern unsigned int count_divecomputers(void); extern void delete_current_divecomputer(void); /* @@ -737,7 +737,7 @@ extern void copy_samples(struct divecomputer *s, struct divecomputer *d); extern bool is_cylinder_used(struct dive *dive, int idx); extern void fill_default_cylinder(cylinder_t *cyl); extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx); -extern struct event *add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name); +extern struct event *add_event(struct divecomputer *dc, unsigned int time, int type, int flags, int value, const char *name); extern void remove_event(struct event *event); extern void update_event_name(struct dive *d, struct event* event, char *name); extern void add_extra_data(struct divecomputer *dc, const char *key, const char *value); @@ -892,7 +892,7 @@ extern depth_t string_to_depth(const char *str); extern pressure_t string_to_pressure(const char *str); extern volume_t string_to_volume(const char *str, pressure_t workp); extern fraction_t string_to_fraction(const char *str); -extern void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth); +extern void average_max_depth(struct diveplan *dive, unsigned int *avg_depth, unsigned int *max_depth); #include "pref.h" diff --git a/subsurface-core/units.h b/subsurface-core/units.h index 9ad4b7282..029bb64fa 100644 --- a/subsurface-core/units.h +++ b/subsurface-core/units.h @@ -99,7 +99,7 @@ typedef struct typedef struct { - int32_t mkelvin; // up to 1750 degrees K + uint32_t mkelvin; // up to 1750 degrees K (temperatures in K are always positive) } temperature_t; typedef struct |