summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2011-10-27 21:32:28 +0000
committerTim Angus <tim@ngus.net>2013-01-10 23:38:31 +0000
commit43285fefafed6821fb277c71da7b28d5291d87dd (patch)
tree0226ebc695a8b5964f98385aa0ba842bf44065b4
parent6fa292451d11608d1588f1b28569ccb2dd1cea57 (diff)
* Fix various warnings with GCC and clang
-rw-r--r--Makefile6
-rw-r--r--src/client/libmumblelink.c2
-rw-r--r--src/qcommon/common.c5
-rw-r--r--src/qcommon/q_shared.c3
-rw-r--r--src/qcommon/q_shared.h6
-rw-r--r--src/renderer/tr_bsp.c8
-rw-r--r--src/sys/con_tty.c19
7 files changed, 30 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 0af4d137..31bd625b 100644
--- a/Makefile
+++ b/Makefile
@@ -268,7 +268,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
endif
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
- -Wno-self-assign -pipe -DUSE_ICON
+ -pipe -DUSE_ICON
CLIENT_CFLAGS += $(SDL_CFLAGS)
OPTIMIZEVM = -O3 -funroll-loops -fomit-frame-pointer
@@ -879,6 +879,10 @@ else
RENDERER_LIBS += -ljpeg
endif
+ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
+ BASE_CFLAGS += -Qunused-arguments
+endif
+
ifdef DEFAULT_BASEDIR
BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\"
endif
diff --git a/src/client/libmumblelink.c b/src/client/libmumblelink.c
index 25ca6786..48a18065 100644
--- a/src/client/libmumblelink.c
+++ b/src/client/libmumblelink.c
@@ -116,7 +116,7 @@ int mumble_link(const char* name)
close(shmfd);
#endif
memset(lm, 0, sizeof(LinkedMem));
- mbstowcs(lm->name, name, sizeof(lm->name));
+ mbstowcs(lm->name, name, sizeof(lm->name) / sizeof(wchar_t));
return 0;
}
diff --git a/src/qcommon/common.c b/src/qcommon/common.c
index be91b245..c2d5d353 100644
--- a/src/qcommon/common.c
+++ b/src/qcommon/common.c
@@ -2325,10 +2325,7 @@ A way to force a bus error for development reasons
=================
*/
static void Com_Crash_f( void ) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnull-dereference"
- * ( int * ) 0 = 0x12345678;
-#pragma clang diagnostic pop
+ * ( volatile int * ) 0 = 0x12345678;
}
/*
diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c
index 00473dbf..68be72ab 100644
--- a/src/qcommon/q_shared.c
+++ b/src/qcommon/q_shared.c
@@ -707,11 +707,12 @@ int Q_isalpha( int c )
qboolean Q_isanumber( const char *s )
{
char *p;
+ double UNUSED_VAR d;
if( *s == '\0' )
return qfalse;
- strtod( s, &p );
+ d = strtod( s, &p );
return *p == '\0';
}
diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h
index e007ae24..87750692 100644
--- a/src/qcommon/q_shared.h
+++ b/src/qcommon/q_shared.h
@@ -83,6 +83,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#endif
+#ifdef __GNUC__
+#define UNUSED_VAR __attribute__((unused))
+#else
+#define UNUSED_VAR
+#endif
+
#if (defined _MSC_VER)
#define Q_EXPORT __declspec(dllexport)
#elif (defined __SUNPRO_C)
diff --git a/src/renderer/tr_bsp.c b/src/renderer/tr_bsp.c
index 4a7c0312..3ca40f08 100644
--- a/src/renderer/tr_bsp.c
+++ b/src/renderer/tr_bsp.c
@@ -273,11 +273,11 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) {
shader_t *shader;
dshader_t *dsh;
- shaderNum = LittleLong( shaderNum );
- if ( shaderNum < 0 || shaderNum >= s_worldData.numShaders ) {
- ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", shaderNum );
+ int _shaderNum = LittleLong( shaderNum );
+ if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) {
+ ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum );
}
- dsh = &s_worldData.shaders[ shaderNum ];
+ dsh = &s_worldData.shaders[ _shaderNum ];
if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
lightmapNum = LIGHTMAP_BY_VERTEX;
diff --git a/src/sys/con_tty.c b/src/sys/con_tty.c
index 20afab4c..0d8da734 100644
--- a/src/sys/con_tty.c
+++ b/src/sys/con_tty.c
@@ -90,13 +90,14 @@ send "\b \b"
static void CON_Back( void )
{
char key;
+ size_t UNUSED_VAR size;
key = '\b';
- write(STDOUT_FILENO, &key, 1);
+ size = write(STDOUT_FILENO, &key, 1);
key = ' ';
- write(STDOUT_FILENO, &key, 1);
+ size = write(STDOUT_FILENO, &key, 1);
key = '\b';
- write(STDOUT_FILENO, &key, 1);
+ size = write(STDOUT_FILENO, &key, 1);
}
/*
@@ -147,12 +148,13 @@ static void CON_Show( void )
ttycon_hide--;
if (ttycon_hide == 0)
{
- write(STDOUT_FILENO, "]", 1);
+ size_t UNUSED_VAR size;
+ size = write(STDOUT_FILENO, "]", 1);
if (TTY_con.cursor)
{
for (i=0; i<TTY_con.cursor; i++)
{
- write(STDOUT_FILENO, TTY_con.buffer+i, 1);
+ size = write(STDOUT_FILENO, TTY_con.buffer+i, 1);
}
}
}
@@ -329,6 +331,7 @@ char *CON_Input( void )
int avail;
char key;
field_t *history;
+ size_t UNUSED_VAR size;
if(ttycon_on)
{
@@ -358,8 +361,8 @@ char *CON_Input( void )
Q_strncpyz(text, TTY_con.buffer, sizeof(text));
Field_Clear(&TTY_con);
key = '\n';
- write(STDOUT_FILENO, &key, 1);
- write(STDOUT_FILENO, "]", 1);
+ size = write(STDOUT_FILENO, &key, 1);
+ size = write(STDOUT_FILENO, "]", 1);
return text;
}
if (key == '\t')
@@ -423,7 +426,7 @@ char *CON_Input( void )
TTY_con.buffer[TTY_con.cursor] = key;
TTY_con.cursor++;
// print the current line (this is differential)
- write(STDOUT_FILENO, &key, 1);
+ size = write(STDOUT_FILENO, &key, 1);
}
return NULL;