From e63490fcdb151ab113c626d131af1b24dc0d1440 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 31 Jan 2023 22:33:54 +0100 Subject: Silence false warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libglitter_redistribute_energy_double.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'libglitter_redistribute_energy_double.c') diff --git a/libglitter_redistribute_energy_double.c b/libglitter_redistribute_energy_double.c index 6b57c0e..24d6c4a 100644 --- a/libglitter_redistribute_energy_double.c +++ b/libglitter_redistribute_energy_double.c @@ -3,12 +3,33 @@ #ifndef TEST +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfloat-equal" +#elif defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wfloat-equal" +#endif + +static int +exactly(double a, double b) +{ + return a == b; +} + +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#elif defined(__clang__) +# pragma clang diagnostic pop +#endif + + static void vconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height, size_t kernelsize, const double *kernel) { size_t y, x, i; - if (kernelsize == 3 && kernel[0] == kernel[1] && kernel[1] == kernel[2]) { + if (kernelsize == 3 && exactly(kernel[0], kernel[1]) && exactly(kernel[1], kernel[2])) { for (y = 0; y < height; y++) { for (x = 0; x < width; x++) raster[x] += raster[x + 1 * rowsize]; @@ -50,7 +71,7 @@ hconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height, { size_t y, x, i; - if (kernelsize == 3 && kernel[0] == kernel[1] && kernel[1] == kernel[2]) { + if (kernelsize == 3 && exactly(kernel[0], kernel[1]) && exactly(kernel[1], kernel[2])) { for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { raster[x + 1] += raster[x + 2]; -- cgit v1.2.3-70-g09d2