summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Kendrick (humdrum) <rob.kendrick@codethink.co.uk>2013-04-25 14:13:36 (GMT)
committer Rob Kendrick (humdrum) <rob.kendrick@codethink.co.uk>2013-04-25 14:13:36 (GMT)
commitfb5c3f3169d3a8d1e85626914b55825733b5376c (patch)
treefcbd30f7b9c369b0c1dbf1930d87eb8e6029843e
parent9aeab2e5176285583f8d669ba79ce6ff45b81a00 (diff)
downloadlibnsfb-rjek/clang-warnings.tar.gz
libnsfb-rjek/clang-warnings.tar.bz2
Rationalise UNUSED macros. This changeset allows libnsfb to berjek/clang-warnings
built warning-free both with Clang 3.3 (from trunk) and GCC 4.7. Remove the use of GCC-specific __attribute__ ((unused)) as this only works on declarations, meaning there is no "fallback" to use on compilers that are not GCC or clang. The (void)foo; approach works with both clang and GCC, and hopefully other compilers people might be using. The alternative would to have been two UNUSED macros, one for use in definitions, and one for use in function bodies.
-rw-r--r--include/nsfb.h3
-rw-r--r--src/plot/16bpp.c8
-rw-r--r--src/plot/32bpp-xbgr8888.c15
-rw-r--r--src/plot/32bpp-xrgb8888.c15
-rw-r--r--src/plot/generic.c14
-rw-r--r--src/surface/linux.c3
-rw-r--r--src/surface/ram.c2
-rw-r--r--src/surface/sdl.c8
-rw-r--r--src/surface/surface.c2
-rw-r--r--src/surface/vnc.c2
10 files changed, 34 insertions, 38 deletions
diff --git a/include/nsfb.h b/include/nsfb.h
index 9a61775..1332695 100644
--- a/include/nsfb.h
+++ b/include/nsfb.h
@@ -13,6 +13,9 @@
#include <stdint.h>
+#ifndef UNUSED
+# define UNUSED(x) (void) (x)
+#endif
/** NS Framebuffer context
*/
diff --git a/src/plot/16bpp.c b/src/plot/16bpp.c
index d629944..9aa7ab1 100644
--- a/src/plot/16bpp.c
+++ b/src/plot/16bpp.c
@@ -18,23 +18,23 @@
#include "nsfb.h"
#include "plot.h"
-#define UNUSED __attribute__((unused))
-
static inline uint16_t *get_xy_loc(nsfb_t *nsfb, int x, int y)
{
return (void *)(nsfb->ptr + (y * nsfb->linelen) + (x << 1));
}
-static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint16_t pixel)
+static inline nsfb_colour_t pixel_to_colour(nsfb_t *nsfb, uint16_t pixel)
{
+ UNUSED(nsfb);
return ((pixel & 0x1F) << 19) |
((pixel & 0x7E0) << 5) |
((pixel & 0xF800) >> 8);
}
/* convert a colour value to a 16bpp pixel value ready for screen output */
-static inline uint16_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
+static inline uint16_t colour_to_pixel(nsfb_t *nsfb, nsfb_colour_t c)
{
+ UNUSED(nsfb);
return ((c & 0xF8) << 8) | ((c & 0xFC00 ) >> 5) | ((c & 0xF80000) >> 19);
}
diff --git a/src/plot/32bpp-xbgr8888.c b/src/plot/32bpp-xbgr8888.c
index 9050903..07613ff 100644
--- a/src/plot/32bpp-xbgr8888.c
+++ b/src/plot/32bpp-xbgr8888.c
@@ -18,36 +18,37 @@
#include "nsfb.h"
#include "plot.h"
-
-#define UNUSED __attribute__((unused))
-
static inline uint32_t *get_xy_loc(nsfb_t *nsfb, int x, int y)
{
return (void *)(nsfb->ptr + (y * nsfb->linelen) + (x << 2));
}
#if __BYTE_ORDER == __BIG_ENDIAN
-static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
+static inline nsfb_colour_t pixel_to_colour(nsfb_t *nsfb, uint32_t pixel)
{
+ UNUSED(nsfb);
/* TODO: FIX */
return (pixel >> 8) & ~0xFF000000U;
}
/* convert a colour value to a 32bpp pixel value ready for screen output */
-static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
+static inline uint32_t colour_to_pixel(nsfb_t *nsfb, nsfb_colour_t c)
{
+ UNUSED(nsfb);
/* TODO: FIX */
return (c << 8);
}
#else /* __BYTE_ORDER == __BIG_ENDIAN */
-static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
+static inline nsfb_colour_t pixel_to_colour(nsfb_t *nsfb, uint32_t pixel)
{
+ UNUSED(nsfb);
return pixel | 0xFF000000U;
}
/* convert a colour value to a 32bpp pixel value ready for screen output */
-static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
+static inline uint32_t colour_to_pixel(nsfb_t *nsfb, nsfb_colour_t c)
{
+ UNUSED(nsfb);
return c;
}
#endif
diff --git a/src/plot/32bpp-xrgb8888.c b/src/plot/32bpp-xrgb8888.c
index 548c970..fb69d91 100644
--- a/src/plot/32bpp-xrgb8888.c
+++ b/src/plot/32bpp-xrgb8888.c
@@ -18,36 +18,37 @@
#include "nsfb.h"
#include "plot.h"
-
-#define UNUSED __attribute__((unused))
-
static inline uint32_t *get_xy_loc(nsfb_t *nsfb, int x, int y)
{
return (void *)(nsfb->ptr + (y * nsfb->linelen) + (x << 2));
}
#if __BYTE_ORDER == __BIG_ENDIAN
-static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
+static inline nsfb_colour_t pixel_to_colour(nsfb_t *nsfb, uint32_t pixel)
{
+ UNUSED(nsfb);
return (pixel >> 8) & ~0xFF000000U;
}
/* convert a colour value to a 32bpp pixel value ready for screen output */
-static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
+static inline uint32_t colour_to_pixel(nsfb_t *nsfb, nsfb_colour_t c)
{
+ UNUSED(nsfb);
return (c << 8);
}
#else /* __BYTE_ORDER == __BIG_ENDIAN */
-static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
+static inline nsfb_colour_t pixel_to_colour(nsfb_t *nsfb, uint32_t pixel)
{
+ UNUSED(nsfb);
return ((pixel & 0xFF) << 16) |
((pixel & 0xFF00)) |
((pixel & 0xFF0000) >> 16);
}
/* convert a colour value to a 32bpp pixel value ready for screen output */
-static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
+static inline uint32_t colour_to_pixel(nsfb_t *nsfb, nsfb_colour_t c)
{
+ UNUSED(nsfb);
return ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
}
#endif
diff --git a/src/plot/generic.c b/src/plot/generic.c
index 0c3d9e8..87c55c5 100644
--- a/src/plot/generic.c
+++ b/src/plot/generic.c
@@ -605,13 +605,13 @@ copy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
static bool arc(nsfb_t *nsfb, int x, int y, int radius, int angle1, int angle2, nsfb_colour_t c)
{
- nsfb=nsfb;
- x = x;
- y = y;
- radius = radius;
- c = c;
- angle1=angle1;
- angle2=angle2;
+ UNUSED(nsfb);
+ UNUSED(x);
+ UNUSED(y);
+ UNUSED(radius);
+ UNUSED(c);
+ UNUSED(angle1);
+ UNUSED(angle2);
return true;
}
diff --git a/src/surface/linux.c b/src/surface/linux.c
index b5bf8ad..69a6a97 100644
--- a/src/surface/linux.c
+++ b/src/surface/linux.c
@@ -32,9 +32,6 @@
#include "cursor.h"
-
-#define UNUSED(x) ((x) = (x))
-
#define FB_NAME "/dev/fb0"
struct lnx_priv {
diff --git a/src/surface/ram.c b/src/surface/ram.c
index 4deabda..e2cfa04 100644
--- a/src/surface/ram.c
+++ b/src/surface/ram.c
@@ -18,8 +18,6 @@
#include "surface.h"
#include "plot.h"
-#define UNUSED(x) ((x) = (x))
-
static int ram_defaults(nsfb_t *nsfb)
{
nsfb->width = 0;
diff --git a/src/surface/sdl.c b/src/surface/sdl.c
index 48052a8..8d2930e 100644
--- a/src/surface/sdl.c
+++ b/src/surface/sdl.c
@@ -502,7 +502,7 @@ static int sdl_initialise(nsfb_t *nsfb)
static int sdl_finalise(nsfb_t *nsfb)
{
- nsfb=nsfb;
+ UNUSED(nsfb);
SDL_Quit();
return 0;
}
@@ -510,8 +510,8 @@ static int sdl_finalise(nsfb_t *nsfb)
static uint32_t wakeeventtimer(uint32_t ival, void *param)
{
SDL_Event event;
- ival = ival;
- param = param;
+ UNUSED(ival);
+ UNUSED(param);
event.type = SDL_USEREVENT;
event.user.code = 0;
@@ -528,7 +528,7 @@ static bool sdl_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
int got_event;
SDL_Event sdlevent;
- nsfb = nsfb; /* unused */
+ UNUSED(nsfb);
if (timeout == 0) {
got_event = SDL_PollEvent(&sdlevent);
diff --git a/src/surface/surface.c b/src/surface/surface.c
index f3127bd..c728bad 100644
--- a/src/surface/surface.c
+++ b/src/surface/surface.c
@@ -17,8 +17,6 @@
#define MAX_SURFACES 16
-#define UNUSED(x) ((x) = (x))
-
struct nsfb_surface_s {
enum nsfb_type_e type;
const nsfb_surface_rtns_t *rtns;
diff --git a/src/surface/vnc.c b/src/surface/vnc.c
index ca9455b..a09a8a2 100644
--- a/src/surface/vnc.c
+++ b/src/surface/vnc.c
@@ -21,8 +21,6 @@
#include "plot.h"
#include "cursor.h"
-#define UNUSED(x) ((x) = (x))
-
static nsfb_event_t *gevent;
/* vnc special set codes */