Skip to content

Commit 4934b2e

Browse files
committed
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 <[email protected]>
1 parent 4f32b8f commit 4934b2e

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/ccstruct/polyblk.cpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "config_auto.h"
2828
#endif
2929

30-
#define PBLOCK_LABEL_SIZE 150
3130
#define INTERSECTING INT16_MAX
3231

3332
int lessthan(const void *first, const void *second);
@@ -191,8 +190,8 @@ void POLY_BLOCK::rotate(FCOORD rotation) {
191190
pos.set_x (pt->x ());
192191
pos.set_y (pt->y ());
193192
pos.rotate (rotation);
194-
pt->set_x ((int16_t) (floor (pos.x () + 0.5)));
195-
pt->set_y ((int16_t) (floor (pos.y () + 0.5)));
193+
pt->set_x(static_cast<int16_t>(floor(pos.x() + 0.5)));
194+
pt->set_y(static_cast<int16_t>(floor(pos.y() + 0.5)));
196195
pts.forward ();
197196
}
198197
while (!pts.at_first ());
@@ -289,7 +288,7 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
289288
// Last pixel is start pixel + length.
290289
width = s_it.data ()->y ();
291290
window->SetCursor(s_it.data ()->x (), y);
292-
window->DrawTo(s_it.data ()->x () + (float) width, y);
291+
window->DrawTo(s_it.data()->x() + static_cast<float>(width), y);
293292
}
294293
}
295294
}
@@ -343,9 +342,7 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) {
343342
ICOORDELT_IT v, r;
344343
ICOORDELT_LIST *result;
345344
ICOORDELT *x, *current, *previous;
346-
float fy, fx;
347-
348-
fy = (float) (y + 0.5);
345+
float fy = y + 0.5f;
349346
result = new ICOORDELT_LIST ();
350347
r.set_to_list (result);
351348
v.set_to_list (block->points ());
@@ -355,11 +352,10 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) {
355352
|| ((v.data_relative (-1)->y () <= y) && (v.data ()->y () > y))) {
356353
previous = v.data_relative (-1);
357354
current = v.data ();
358-
fx = (float) (0.5 + previous->x () +
359-
(current->x () - previous->x ()) * (fy -
360-
previous->y ()) /
361-
(current->y () - previous->y ()));
362-
x = new ICOORDELT ((int16_t) fx, 0);
355+
float fx = 0.5f + previous->x() +
356+
(current->x() - previous->x()) * (fy - previous->y()) /
357+
(current->y() - previous->y());
358+
x = new ICOORDELT(static_cast<int16_t>(fx), 0);
363359
r.add_to_end (x);
364360
}
365361
}
@@ -380,8 +376,8 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) {
380376

381377

382378
int lessthan(const void *first, const void *second) {
383-
ICOORDELT *p1 = (*(ICOORDELT **) first);
384-
ICOORDELT *p2 = (*(ICOORDELT **) second);
379+
const ICOORDELT *p1 = *reinterpret_cast<const ICOORDELT* const*>(first);
380+
const ICOORDELT *p2 = *reinterpret_cast<const ICOORDELT* const*>(second);
385381

386382
if (p1->x () < p2->x ())
387383
return (-1);

0 commit comments

Comments
 (0)