Skip to content

Commit 9adf0e2

Browse files
hughbeakoeplinger
authored andcommitted
Fix unused variable warnings in libgdiplus (mono#514)
* Fix unused variable warnings * Remove blocking warnings from src makefile * Remove unecessary -Wall in src makefile Already defined in `GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -std=gnu99"`
1 parent 70711a3 commit 9adf0e2

14 files changed

+22
-72
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ endif
129129

130130
libgdiplus_la_LIBADD = $(GDIPLUS_LIBS)
131131

132-
AM_CPPFLAGS = $(GDIPLUS_CFLAGS) -Wall -Wno-unused -Wno-format
132+
AM_CPPFLAGS = $(GDIPLUS_CFLAGS)
133133

134134
EXTRA_DIST = libgdiplus.vcxproj packages.config

src/bitmap.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,16 +2001,6 @@ GdipBitmapUnlockBits (GpBitmap *bitmap, BitmapData *lockedBitmapData)
20012001
return status;
20022002
}
20032003

2004-
static void gdip_setpixel_32bppARGB (BYTE *scan, INT x, BYTE a, BYTE r, BYTE g, BYTE b)
2005-
{
2006-
set_pixel_bgra (scan, x, a, r, g, b);
2007-
}
2008-
2009-
static void gdip_setpixel_32bppRGB (BYTE *scan, INT x, BYTE a, BYTE r, BYTE g, BYTE b)
2010-
{
2011-
set_pixel_bgra (scan, x, a, r, g, b);
2012-
}
2013-
20142004
GpStatus WINGDIPAPI
20152005
GdipBitmapSetPixel (GpBitmap *bitmap, INT x, INT y, ARGB color)
20162006
{

src/emfcodec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ PolyBezier (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
137137
#ifdef DEBUG_EMF
138138
printf ("PolyBezier%s bounds [%d, %d, %d, %d] with %d points", (compact ? "16" : ""),
139139
bounds.left, bounds.top, bounds.right, bounds.bottom, num);
140+
#else
141+
(void) bounds; // Avoid an unused variable warning.
140142
#endif
141143

142144
/* we need to supply the current x,y position */
@@ -215,6 +217,8 @@ Polygon (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
215217
#ifdef DEBUG_EMF
216218
printf ("Polygon%s bounds [%d, %d, %d, %d] with %d points", (compact ? "16" : ""),
217219
bounds.left, bounds.top, bounds.right, bounds.bottom, num);
220+
#else
221+
(void) bounds; // Avoid an unused variable warning.
218222
#endif
219223

220224
points = (GpPointF*) GdipAlloc (num * sizeof (GpPointF));
@@ -277,7 +281,10 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data, BOOL compact)
277281
#ifdef DEBUG_EMF
278282
printf ("PolyPolygon%s bounds [%d, %d, %d, %d] with %d polygons", (compact ? "16" : ""),
279283
bounds.left, bounds.top, bounds.right, bounds.bottom, poly_num);
284+
#else
285+
(void) bounds; // Avoid an unused variable warning.
280286
#endif
287+
281288
/* read size of each polygon and allocate the required memory */
282289
for (i = 0; i < poly_num; i++) {
283290
current->num = GETDW(DWP(n));

src/general-private.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
#define max(a,b) (a > b ? a : b)
6161
#endif
6262

63+
#if !defined(__has_attribute)
64+
#define __has_attribute(x) 0
65+
#endif
66+
67+
#if __has_attribute(used) || defined(__GNUC__)
68+
#define ATTRIBUTE_USED __attribute__((used))
69+
#else
70+
#define ATTRIBUTE_USED
71+
#endif
72+
6373
/* avoid direct floating point comparison */
6474
#define gdip_near_zero(value) ((value >= -0.00059604645f) && (value <= 0.00059604645f))
6575
#define gdip_near_one(value) gdip_near_zero (value - 1.0f)

src/graphics-cairo.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -621,28 +621,6 @@ make_polygon (GpGraphics *graphics, GDIPCONST GpPointF *points, int count, BOOL
621621
cairo_close_path (graphics->ct);
622622
}
623623

624-
static void
625-
make_polygon_from_integers (GpGraphics *graphics, GDIPCONST GpPoint *points, int count, BOOL antialiasing)
626-
{
627-
int i;
628-
629-
gdip_cairo_move_to (graphics, points [0].X, points [0].Y, TRUE, antialiasing);
630-
631-
for (i = 0; i < count; i++) {
632-
gdip_cairo_line_to (graphics, points [i].X, points [i].Y, TRUE, antialiasing);
633-
}
634-
635-
/*
636-
* Draw a line from the last point back to the first point if
637-
* they're not the same
638-
*/
639-
if (points [0].X != points [count-1].X && points [0].Y != points [count-1].Y) {
640-
gdip_cairo_line_to (graphics, points [0].X, points [0].Y, TRUE, antialiasing);
641-
}
642-
643-
cairo_close_path (graphics->ct);
644-
}
645-
646624
GpStatus
647625
cairo_DrawPolygon (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, int count)
648626
{
@@ -731,7 +709,6 @@ cairo_FillRegion (GpGraphics *graphics, GpBrush *brush, GpRegion *region)
731709
if (region->type == RegionTypePath) {
732710
GpStatus status;
733711
cairo_surface_t *mask_surface;
734-
GpBitmap *bitmap = NULL;
735712

736713
/* (optimization) if if the path is empty, return immediately */
737714
if (!region->tree)

src/graphics-metafile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@
3333
#define EMFPLUS_FLAGS_USE_INT160x4000
3434
#define EMFPLUS_FLAGS_USE_ARGB0x8000
3535

36-
static BOOL
36+
ATTRIBUTE_USED static BOOL
3737
RectFitInInt16 (int x, int y, int width, int height)
3838
{
3939
return (FIT_IN_INT16(x) && FIT_IN_INT16(y) && FIT_IN_INT16(width) && FIT_IN_INT16(height));
4040
}
4141

42-
static BOOL
42+
ATTRIBUTE_USED static BOOL
4343
GpRectFitInInt16 (GDIPCONST GpRect *rect)
4444
{
4545
return (FIT_IN_INT16(rect->X) && FIT_IN_INT16(rect->Y) && FIT_IN_INT16(rect->Width) && FIT_IN_INT16(rect->Height));
4646
}
4747

48-
static BOOL
48+
ATTRIBUTE_USED static BOOL
4949
GpRectArrayFitInInt16 (GDIPCONST GpRect *rects, int count)
5050
{
5151
GpRect *r = (GpRect*) rects;

src/graphics-path.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,6 @@ GpStatus WINGDIPAPI
362362
GdipClonePath (GpPath *path, GpPath **clonePath)
363363
{
364364
GpPath *result;
365-
int i;
366-
BYTE type;
367-
GpPointF point;
368365

369366
if (!path || !clonePath)
370367
return InvalidParameter;
@@ -599,8 +596,7 @@ GdipClearPathMarkers (GpPath *path)
599596
static void
600597
reverse_subpath_adjust_flags (int start, int end, BYTE *types, BOOL *prev_had_marker)
601598
{
602-
BYTE t, prev_last;
603-
int i;
599+
BYTE prev_last;
604600

605601
/* Copy all but PathPointTypeStart */
606602
if (end != start)
@@ -629,7 +625,6 @@ GpStatus WINGDIPAPI
629625
GdipReversePath (GpPath *path)
630626
{
631627
int length, i;
632-
GByteArray *types;
633628
int start = 0;
634629
BOOL prev_had_marker = FALSE;
635630

@@ -1188,11 +1183,6 @@ GdipAddPathPolygon (GpPath *path, const GpPointF *points, int count)
11881183
GpStatus WINGDIPAPI
11891184
GdipAddPathPath (GpPath *path, GDIPCONST GpPath *addingPath, BOOL connect)
11901185
{
1191-
int i, length;
1192-
PathPointType first;
1193-
GpPointF *pts;
1194-
BYTE *types;
1195-
11961186
if (!path || !addingPath)
11971187
return InvalidParameter;
11981188

@@ -1672,10 +1662,6 @@ static BOOL
16721662
gdip_convert_bezier_to_lines (GpPath *path, int index, float flatness, GpPath *flat_path)
16731663
{
16741664
GpPointF start, first, second, end;
1675-
GpPointF pt;
1676-
BYTE type;
1677-
int i;
1678-
int points_len = 0;
16791665
int saved_count;
16801666

16811667
if ((index <= 0) || (index + 2 >= path->count))
@@ -1704,8 +1690,6 @@ GdipFlattenPath (GpPath *path, GpMatrix *matrix, float flatness)
17041690
{
17051691
GpStatus status = Ok;
17061692
GpPath *flat_path;
1707-
GArray *points;
1708-
GByteArray *types;
17091693
int i;
17101694

17111695
if (!path)
@@ -1735,7 +1719,6 @@ GdipFlattenPath (GpPath *path, GpMatrix *matrix, float flatness)
17351719
if ((type & PathPointTypeBezier) == PathPointTypeBezier) {
17361720
if (!gdip_convert_bezier_to_lines (path, i, fabs (flatness), flat_path)) {
17371721
/* uho, too much recursion - do not pass go, do not collect 200$ */
1738-
GpPointF pt;
17391722

17401723
/* free the the partial flat */
17411724
GdipResetPath (flat_path);

src/graphics-pathiterator.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ GdipDeletePathIter (GpPathIterator *iterator)
124124
GpStatus
125125
GdipPathIterCopyData (GpPathIterator *iterator, int *resultCount, GpPointF *points, BYTE *types, int startIndex, int endIndex)
126126
{
127-
int i, j;
128-
129127
if (!iterator || !resultCount || !points || !types)
130128
return InvalidParameter;
131129

src/graphics.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ GdipResetWorldTransform (GpGraphics *graphics)
646646
GpStatus WINGDIPAPI
647647
GdipSetWorldTransform (GpGraphics *graphics, GpMatrix *matrix)
648648
{
649-
GpStatus status;
650649
BOOL invertible;
651650

652651
if (!graphics)
@@ -2128,8 +2127,6 @@ GdipSetClipRegion (GpGraphics *graphics, GpRegion *region, CombineMode combineMo
21282127
GpStatus WINGDIPAPI
21292128
GdipSetClipHrgn (GpGraphics *graphics, void *hRgn, CombineMode combineMode)
21302129
{
2131-
GpStatus status;
2132-
21332130
if (!graphics)
21342131
return InvalidParameter;
21352132
if (graphics->state == GraphicsStateBusy)

src/metafile.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,9 +1356,6 @@ gdip_read_emf_header_optionals (ENHMETAHEADER3 *header, void *pointer, ImageSour
13561356
const int HeaderRecordSize = sizeof (ENHMETAHEADER3);
13571357
const int HeaderExtension1Size = sizeof (ENHMETAHEADER3) + sizeof (HeaderExtension1);
13581358

1359-
int originalHeaderSize = header->nSize;
1360-
DWORD key;
1361-
13621359
/* Initialize header size to minimum. */
13631360
int headerSize = HeaderRecordSize;
13641361

0 commit comments

Comments
 (0)