aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2014-12-31 01:17:50 -0500
committerJon Lund Steffensen <jonlst@gmail.com>2015-01-04 16:32:47 -0500
commit017fc230be20bf3be605559fcb4cadccaa89b098 (patch)
tree8b1276bbb313474767798a814999f77e83f7beaa /src
parentredshift: Add transition scheme type with color settings (diff)
downloadredshift-ng-017fc230be20bf3be605559fcb4cadccaa89b098.tar.gz
redshift-ng-017fc230be20bf3be605559fcb4cadccaa89b098.tar.bz2
redshift-ng-017fc230be20bf3be605559fcb4cadccaa89b098.tar.xz
redshift: Add gamma_is_valid function to check gamma
This checks whether the gamma values are within the bounds of MIN_GAMMA and MAX_GAMMA.
Diffstat (limited to 'src')
-rw-r--r--src/redshift.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/redshift.c b/src/redshift.c
index b35e9d4..b45507f 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -731,6 +731,19 @@ parse_brightness_string(const char *str, float *bright_day, float *bright_night)
}
}
+/* Check whether gamma is within allowed levels. */
+static int
+gamma_is_valid(const float gamma[3])
+{
+ return !(gamma[0] < MIN_GAMMA ||
+ gamma[0] > MAX_GAMMA ||
+ gamma[1] < MIN_GAMMA ||
+ gamma[1] > MAX_GAMMA ||
+ gamma[2] < MIN_GAMMA ||
+ gamma[2] > MAX_GAMMA);
+
+}
+
static const gamma_method_t *
find_gamma_method(const char *name)
{
@@ -1511,18 +1524,8 @@ main(int argc, char *argv[])
}
/* Gamma */
- if (scheme.day.gamma[0] < MIN_GAMMA ||
- scheme.day.gamma[0] > MAX_GAMMA ||
- scheme.day.gamma[1] < MIN_GAMMA ||
- scheme.day.gamma[1] > MAX_GAMMA ||
- scheme.day.gamma[2] < MIN_GAMMA ||
- scheme.day.gamma[2] > MAX_GAMMA ||
- scheme.night.gamma[0] < MIN_GAMMA ||
- scheme.night.gamma[0] > MAX_GAMMA ||
- scheme.night.gamma[1] < MIN_GAMMA ||
- scheme.night.gamma[1] > MAX_GAMMA ||
- scheme.night.gamma[2] < MIN_GAMMA ||
- scheme.night.gamma[2] > MAX_GAMMA) {
+ if (!gamma_is_valid(scheme.day.gamma) ||
+ !gamma_is_valid(scheme.night.gamma)) {
fprintf(stderr,
_("Gamma value must be between %.1f and %.1f.\n"),
MIN_GAMMA, MAX_GAMMA);