From 449407245568ce8a96a142923c388d6bfdfe5d34 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 12 Nov 2022 15:53:05 -0800 Subject: [PATCH] core plugin: suppress 'offset' double comparison warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This code is trying to abbreviate printing `0.000` or `1.000`. We can more accurately describe the situations under which this will happen, squashing: gvrender_core_svg.c: In function ‘svg_print_stop’: gvrender_core_svg.c:525:16: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 525 | if (offset == 0.0) | ^~ gvrender_core_svg.c:527:21: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 527 | else if (offset == 1.0) | ^~ --- plugin/core/gvrender_core_svg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index e26bc0d42..76ceb7f81 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -534,9 +534,9 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) static void svg_print_stop(GVJ_t * job, double offset, gvcolor_t color) { - if (offset == 0.0) + if (fabs(offset - 0.0) < 0.0005) gvputs(job, "