aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-31 22:33:54 +0100
committerMattias Andrée <maandree@kth.se>2023-01-31 22:33:54 +0100
commite63490fcdb151ab113c626d131af1b24dc0d1440 (patch)
treeb21e3d42b5723d207ba6ad956170366c1ed80445
parentlibglitter_redistribute_energy_double: add more tests and fix typo in code (diff)
downloadlibglitter-1.1.tar.gz
libglitter-1.1.tar.bz2
libglitter-1.1.tar.xz
Silence false warnings1.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--common.h1
-rw-r--r--libglitter_redistribute_energy_double.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/common.h b/common.h
index 3a70c71..33b54dc 100644
--- a/common.h
+++ b/common.h
@@ -55,6 +55,7 @@ struct libglitter_render_context {
# pragma GCC diagnostic ignored "-Wdouble-promotion"
#elif defined(__clang__)
# pragma clang diagnostic ignored "-Wfloat-equal"
+# pragma clang diagnostic ignored "-Wfloat-conversion"
# pragma clang diagnostic ignored "-Wdouble-promotion"
# pragma clang diagnostic ignored "-Wimplicit-float-conversion"
#endif
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];