]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
space-flares: Fix compiler warning
authorHans de Goede <hdegoede@redhat.com>
Mon, 30 Sep 2019 09:12:45 +0000 (11:12 +0200)
committerHans de Goede <hdegoede@redhat.com>
Mon, 30 Sep 2019 09:15:31 +0000 (11:15 +0200)
Recent gcc versions give the following compiler warning with space-flares:
./plugin.c: In function ‘star_bg_update’:
./plugin.c:762:21: warning: taking the absolute value of unsigned type ‘uint32_t’ {aka ‘unsigned int’} has no effect [-Wabsolute-value]
  762 |                 if (abs (((image_data[x + y * width] >> 16) & 0xff) - ((pixel_colour >> 16) & 0xff)) > 8) {
      |                     ^~~

This commit fixes this, assuming that gcc actually optimises the abs()
away, this will also make the code behave as intended again.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/plugins/splash/space-flares/plugin.c

index 5af99c11912491b8242269102877d8c009b9522c..1b28268fdb5fa91a834d602fb55bc0f68482b107 100644 (file)
@@ -759,7 +759,7 @@ star_bg_update (view_t *view, sprite_t *sprite, double time)
                 x = star_bg->star_x[i];
                 y = star_bg->star_y[i];
                 uint32_t pixel_colour = star_bg_gradient_colour (x, y, width, height, true, time);
-                if (abs (((image_data[x + y * width] >> 16) & 0xff) - ((pixel_colour >> 16) & 0xff)) > 8) {
+                if (abs ((int)((image_data[x + y * width] >> 16) & 0xff) - (int)((pixel_colour >> 16) & 0xff)) > 8) {
                         image_data[x + y * width] = pixel_colour;
                         star_bg->star_refresh[i] = 1;
                 }