diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-05 20:59:57 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-05 20:59:57 +0100 |
commit | 259604f63dba5f958b879813d1eaed9a59991d1e (patch) | |
tree | 15aec3fced6f925fb3dd9d6c5907cf5aaa2a22d0 /src/redshift.c | |
parent | Mention after fork that SIGCHLD is ignored (diff) | |
download | redshift-ng-259604f63dba5f958b879813d1eaed9a59991d1e.tar.gz redshift-ng-259604f63dba5f958b879813d1eaed9a59991d1e.tar.bz2 redshift-ng-259604f63dba5f958b879813d1eaed9a59991d1e.tar.xz |
Fix warnings
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/redshift.c')
-rw-r--r-- | src/redshift.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/redshift.c b/src/redshift.c index bbbb30b..bb01449 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -73,6 +73,20 @@ static const char *period_names[] = { }; +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +static int +exact_eq(double a, double b) +{ + return a == b; +} +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + + /* Determine which period we are currently in based on time offset. */ static enum period get_period_from_time(const struct transition_scheme *transition, int time_offset) @@ -733,13 +747,11 @@ run_continual_mode(const struct location_provider *provider, if (done && fade_length == 0) break; if (verbose) { - if (prev_target_interp.temperature != - target_interp.temperature) { + if (prev_target_interp.temperature != target_interp.temperature) { printf(_("Color temperature: %uK\n"), target_interp.temperature); } - if (prev_target_interp.brightness != - target_interp.brightness) { + if (!exact_eq(prev_target_interp.brightness, target_interp.brightness)) { printf(_("Brightness: %.2f\n"), target_interp.brightness); } @@ -773,7 +785,7 @@ run_continual_mode(const struct location_provider *provider, if (loc_fd >= 0) { struct pollfd pollfds[1]; struct location new_loc; - int r, new_available; + int new_available; /* Provider is dynamic. */ pollfds[0].fd = loc_fd; @@ -809,8 +821,8 @@ run_continual_mode(const struct location_provider *provider, } if (new_available && - (new_loc.lat != loc.lat || - new_loc.lon != loc.lon || + (!exact_eq(new_loc.lat, loc.lat) || + !exact_eq(new_loc.lon, loc.lon) || new_available != location_available)) { loc = new_loc; print_location(&loc); |