From 4934b2e8eb1ec2544852df3062d4bd10a1e45eba Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 3 Sep 2018 11:32:58 +0200 Subject: [PATCH] ccstruct/polyblk.cpp: Fix compiler warnings Compiler warnings from clang: src/ccstruct/polyblk.cpp:194:16: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:195:16: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:292:45: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:30:9: warning: macro is not used [-Wunused-macros] src/ccstruct/polyblk.cpp:348:8: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:358:12: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:362:26: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:383:21: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:383:36: warning: cast from 'const void *' to 'ICOORDELT **' drops const qualifier [-Wcast-qual] src/ccstruct/polyblk.cpp:384:21: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/polyblk.cpp:384:36: warning: cast from 'const void *' to 'ICOORDELT **' drops const qualifier [-Wcast-qual] Signed-off-by: Stefan Weil --- src/ccstruct/polyblk.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/ccstruct/polyblk.cpp b/src/ccstruct/polyblk.cpp index 9d152c6aff..a47e58384d 100644 --- a/src/ccstruct/polyblk.cpp +++ b/src/ccstruct/polyblk.cpp @@ -27,7 +27,6 @@ #include "config_auto.h" #endif -#define PBLOCK_LABEL_SIZE 150 #define INTERSECTING INT16_MAX int lessthan(const void *first, const void *second); @@ -191,8 +190,8 @@ void POLY_BLOCK::rotate(FCOORD rotation) { pos.set_x (pt->x ()); pos.set_y (pt->y ()); pos.rotate (rotation); - pt->set_x ((int16_t) (floor (pos.x () + 0.5))); - pt->set_y ((int16_t) (floor (pos.y () + 0.5))); + pt->set_x(static_cast(floor(pos.x() + 0.5))); + pt->set_y(static_cast(floor(pos.y() + 0.5))); pts.forward (); } while (!pts.at_first ()); @@ -289,7 +288,7 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) { // Last pixel is start pixel + length. width = s_it.data ()->y (); window->SetCursor(s_it.data ()->x (), y); - window->DrawTo(s_it.data ()->x () + (float) width, y); + window->DrawTo(s_it.data()->x() + static_cast(width), y); } } } @@ -343,9 +342,7 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) { ICOORDELT_IT v, r; ICOORDELT_LIST *result; ICOORDELT *x, *current, *previous; - float fy, fx; - - fy = (float) (y + 0.5); + float fy = y + 0.5f; result = new ICOORDELT_LIST (); r.set_to_list (result); v.set_to_list (block->points ()); @@ -355,11 +352,10 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) { || ((v.data_relative (-1)->y () <= y) && (v.data ()->y () > y))) { previous = v.data_relative (-1); current = v.data (); - fx = (float) (0.5 + previous->x () + - (current->x () - previous->x ()) * (fy - - previous->y ()) / - (current->y () - previous->y ())); - x = new ICOORDELT ((int16_t) fx, 0); + float fx = 0.5f + previous->x() + + (current->x() - previous->x()) * (fy - previous->y()) / + (current->y() - previous->y()); + x = new ICOORDELT(static_cast(fx), 0); r.add_to_end (x); } } @@ -380,8 +376,8 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) { int lessthan(const void *first, const void *second) { - ICOORDELT *p1 = (*(ICOORDELT **) first); - ICOORDELT *p2 = (*(ICOORDELT **) second); + const ICOORDELT *p1 = *reinterpret_cast(first); + const ICOORDELT *p2 = *reinterpret_cast(second); if (p1->x () < p2->x ()) return (-1);