diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-09-02 21:21:29 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-07 11:03:30 -0700 |
commit | 2bd0c2143ecfca36ffa38b48d89dad7c57634ea9 (patch) | |
tree | bb8f14ceb4db949ec2e90f75c9b7cfc3ed0aa4dd /core | |
parent | 2635673c3ad89261ef77d554abf648ebe5f4cc89 (diff) | |
download | subsurface-2bd0c2143ecfca36ffa38b48d89dad7c57634ea9.tar.gz |
Cleanup: constify get_units()
get_units() returns a pointer to the units struct in the preferences.
Callers should not modify the preferences via this struct, therefore
make the return value point to const.
This is a small step in constifying the global preferences structure.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/dive.c | 10 | ||||
-rw-r--r-- | core/dive.h | 2 | ||||
-rw-r--r-- | core/save-html.c | 2 | ||||
-rw-r--r-- | core/subsurfacestartup.c | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/core/dive.c b/core/dive.c index 044c969ee..53ca49bfd 100644 --- a/core/dive.c +++ b/core/dive.c @@ -286,7 +286,7 @@ int get_pressure_units(int mb, const char **units) { int pressure; const char *unit; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); switch (units_p->pressure) { case PASCAL: @@ -312,7 +312,7 @@ double get_temp_units(unsigned int mk, const char **units) { double deg; const char *unit; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); if (units_p->temperature == FAHRENHEIT) { deg = mkelvin_to_F(mk); @@ -331,7 +331,7 @@ double get_volume_units(unsigned int ml, int *frac, const char **units) int decimals; double vol; const char *unit; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); switch (units_p->volume) { case LITER: @@ -377,7 +377,7 @@ double get_depth_units(int mm, int *frac, const char **units) int decimals; double d; const char *unit; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); switch (units_p->length) { case METERS: @@ -435,7 +435,7 @@ double get_weight_units(unsigned int grams, int *frac, const char **units) int decimals; double value; const char *unit; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); if (units_p->weight == LBS) { value = grams_to_lbs(grams); diff --git a/core/dive.h b/core/dive.h index 4c24dad74..0cc3150ce 100644 --- a/core/dive.h +++ b/core/dive.h @@ -423,7 +423,7 @@ extern struct dive_trip *clone_empty_trip(struct dive_trip *trip); extern const struct units SI_units, IMPERIAL_units; extern struct units xml_parsing_units; -extern struct units *get_units(void); +extern const struct units *get_units(void); extern int run_survey, verbose, quit, force_root; struct dive_table { diff --git a/core/save-html.c b/core/save-html.c index 38f48e8c4..413718692 100644 --- a/core/save-html.c +++ b/core/save-html.c @@ -273,7 +273,7 @@ void put_HTML_depth(struct membuffer *b, struct dive *dive, const char *pre, con { const char *unit; double value; - struct units *units_p = get_units(); + const struct units *units_p = get_units(); if (!dive->maxdepth.mm) { put_format(b, "%s--%s", pre, post); diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c index f234ac86f..f3f9e4bda 100644 --- a/core/subsurfacestartup.c +++ b/core/subsurfacestartup.c @@ -106,7 +106,7 @@ struct preferences default_prefs = { int run_survey; -struct units *get_units() +const struct units *get_units() { return &prefs.units; } |