[gimp/gimp-2-10] app: fix "Result is not floating-point (UNINTENDED_INTEGER_DIVISION)".



commit dfda00d5f7d423d44c62d2eb2c603df02613607c
Author: Jehan <jehan girinstud io>
Date:   Wed Oct 9 14:43:11 2019 +0200

    app: fix "Result is not floating-point (UNINTENDED_INTEGER_DIVISION)".
    
    See #3996.
    This was a warning raised by the Coverity scan on one of the lines. I
    fix also in the same time other arithmetics mixing int and double.
    Better be thorough.
    The specific warning was on:
    > circ = 2.0 * G_PI * (private->width / 2)
    where the division was integer, which was probably not intended. Of
    course that error (display item only) was likely barely visible anyway,
    still…
    
    (cherry picked from commit c809e221ec65285a4142d5946e1e5147782ee812)

 app/display/gimpcanvashandle.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index 4291affc7c..954eead5ef 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -390,10 +390,10 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
           break;
 
         case GIMP_HANDLE_CROSS:
-          cairo_move_to (cr, x - private->width / 2, y);
-          cairo_line_to (cr, x + private->width / 2 - 0.5, y);
-          cairo_move_to (cr, x, y - private->height / 2);
-          cairo_line_to (cr, x, y + private->height / 2 - 0.5);
+          cairo_move_to (cr, x - private->width / 2.0, y);
+          cairo_line_to (cr, x + private->width / 2.0 - 0.5, y);
+          cairo_move_to (cr, x, y - private->height / 2.0);
+          cairo_line_to (cr, x, y + private->height / 2.0 - 0.5);
           _gimp_canvas_item_stroke (item, cr);
           break;
 
@@ -413,7 +413,7 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
 
           cairo_save (cr);
 
-          circ = 2.0 * G_PI * (private->width / 2);
+          circ = 2.0 * G_PI * (private->width / 2.0);
 
           dashes[0] = (circ / N_DASHES) * DASH_ON_RATIO;
           dashes[1] = (circ / N_DASHES) * DASH_OFF_RATIO;
@@ -421,7 +421,7 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
           cairo_set_dash (cr, dashes, 2, dashes[0] / 2.0);
         }
 
-      gimp_cairo_arc (cr, x, y, private->width / 2,
+      gimp_cairo_arc (cr, x, y, private->width / 2.0,
                       private->start_angle,
                       private->slice_angle);
 
@@ -442,16 +442,16 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
       break;
 
     case GIMP_HANDLE_CROSSHAIR:
-      cairo_move_to (cr, x - private->width / 2, y);
+      cairo_move_to (cr, x - private->width / 2.0, y);
       cairo_line_to (cr, x - private->width * 0.4, y);
 
-      cairo_move_to (cr, x + private->width / 2 - 0.5, y);
+      cairo_move_to (cr, x + private->width / 2.0 - 0.5, y);
       cairo_line_to (cr, x + private->width * 0.4, y);
 
-      cairo_move_to (cr, x, y - private->height / 2);
+      cairo_move_to (cr, x, y - private->height / 2.0);
       cairo_line_to (cr, x, y - private->height * 0.4 - 0.5);
 
-      cairo_move_to (cr, x, y + private->height / 2 - 0.5);
+      cairo_move_to (cr, x, y + private->height / 2.0 - 0.5);
       cairo_line_to (cr, x, y + private->height * 0.4 - 0.5);
 
        _gimp_canvas_item_stroke (item, cr);
@@ -493,8 +493,8 @@ gimp_canvas_handle_get_extents (GimpCanvasItem *item)
     case GIMP_HANDLE_DIAMOND:
     case GIMP_HANDLE_DASHED_DIAMOND:
     case GIMP_HANDLE_FILLED_DIAMOND:
-      rectangle.x      = x - private->width  / 2 - 2.0;
-      rectangle.y      = y - private->height / 2 - 2.0;
+      rectangle.x      = x - private->width  / 2.0 - 2.0;
+      rectangle.y      = y - private->height / 2.0 - 2.0;
       rectangle.width  = private->width  + 4.0;
       rectangle.height = private->height + 4.0;
       break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]