mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2635673c3a
commit
2bd0c2143e
5 changed files with 9 additions and 9 deletions
10
core/dive.c
10
core/dive.c
|
@ -286,7 +286,7 @@ int get_pressure_units(int mb, const char **units)
|
||||||
{
|
{
|
||||||
int pressure;
|
int pressure;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
switch (units_p->pressure) {
|
switch (units_p->pressure) {
|
||||||
case PASCAL:
|
case PASCAL:
|
||||||
|
@ -312,7 +312,7 @@ double get_temp_units(unsigned int mk, const char **units)
|
||||||
{
|
{
|
||||||
double deg;
|
double deg;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
if (units_p->temperature == FAHRENHEIT) {
|
if (units_p->temperature == FAHRENHEIT) {
|
||||||
deg = mkelvin_to_F(mk);
|
deg = mkelvin_to_F(mk);
|
||||||
|
@ -331,7 +331,7 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
|
||||||
int decimals;
|
int decimals;
|
||||||
double vol;
|
double vol;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
switch (units_p->volume) {
|
switch (units_p->volume) {
|
||||||
case LITER:
|
case LITER:
|
||||||
|
@ -377,7 +377,7 @@ double get_depth_units(int mm, int *frac, const char **units)
|
||||||
int decimals;
|
int decimals;
|
||||||
double d;
|
double d;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
switch (units_p->length) {
|
switch (units_p->length) {
|
||||||
case METERS:
|
case METERS:
|
||||||
|
@ -435,7 +435,7 @@ double get_weight_units(unsigned int grams, int *frac, const char **units)
|
||||||
int decimals;
|
int decimals;
|
||||||
double value;
|
double value;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
if (units_p->weight == LBS) {
|
if (units_p->weight == LBS) {
|
||||||
value = grams_to_lbs(grams);
|
value = grams_to_lbs(grams);
|
||||||
|
|
|
@ -423,7 +423,7 @@ extern struct dive_trip *clone_empty_trip(struct dive_trip *trip);
|
||||||
extern const struct units SI_units, IMPERIAL_units;
|
extern const struct units SI_units, IMPERIAL_units;
|
||||||
extern struct units xml_parsing_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;
|
extern int run_survey, verbose, quit, force_root;
|
||||||
|
|
||||||
struct dive_table {
|
struct dive_table {
|
||||||
|
|
|
@ -273,7 +273,7 @@ void put_HTML_depth(struct membuffer *b, struct dive *dive, const char *pre, con
|
||||||
{
|
{
|
||||||
const char *unit;
|
const char *unit;
|
||||||
double value;
|
double value;
|
||||||
struct units *units_p = get_units();
|
const struct units *units_p = get_units();
|
||||||
|
|
||||||
if (!dive->maxdepth.mm) {
|
if (!dive->maxdepth.mm) {
|
||||||
put_format(b, "%s--%s", pre, post);
|
put_format(b, "%s--%s", pre, post);
|
||||||
|
|
|
@ -106,7 +106,7 @@ struct preferences default_prefs = {
|
||||||
|
|
||||||
int run_survey;
|
int run_survey;
|
||||||
|
|
||||||
struct units *get_units()
|
const struct units *get_units()
|
||||||
{
|
{
|
||||||
return &prefs.units;
|
return &prefs.units;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
FILE *f;
|
FILE *f;
|
||||||
QDir texdir = QFileInfo(filename).dir();
|
QDir texdir = QFileInfo(filename).dir();
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
struct units *units = get_units();
|
const struct units *units = get_units();
|
||||||
const char *unit;
|
const char *unit;
|
||||||
int i;
|
int i;
|
||||||
bool need_pagebreak = false;
|
bool need_pagebreak = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue