Get rid of all GCC warnings

This commit is contained in:
def 2015-04-18 21:33:51 +02:00
parent 710a786f88
commit 0ffa79671b
4 changed files with 10 additions and 7 deletions

View file

@ -2377,6 +2377,8 @@ int os_compare_version(int major, int minor)
return 0; return 0;
else else
return -1; return -1;
#else
return 0; // unimplemented
#endif #endif
} }

View file

@ -19,6 +19,7 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include "zlib.h" #include "zlib.h"
#ifdef STDC #ifdef STDC
# include <string.h> # include <string.h>

View file

@ -203,13 +203,13 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
if (State() != NET_CONNSTATE_OFFLINE && m_SecurityToken != NET_SECURITY_TOKEN_UNKNOWN && m_SecurityToken != NET_SECURITY_TOKEN_UNSUPPORTED) if (State() != NET_CONNSTATE_OFFLINE && m_SecurityToken != NET_SECURITY_TOKEN_UNKNOWN && m_SecurityToken != NET_SECURITY_TOKEN_UNSUPPORTED)
{ {
// supposed to have a valid token in this packet, check it // supposed to have a valid token in this packet, check it
if (pPacket->m_DataSize < sizeof(m_SecurityToken)) if (pPacket->m_DataSize < (int)sizeof(m_SecurityToken))
return 0; return 0;
pPacket->m_DataSize -= sizeof(m_SecurityToken); pPacket->m_DataSize -= sizeof(m_SecurityToken);
if (m_SecurityToken != *(SECURITY_TOKEN*)&pPacket->m_aChunkData[pPacket->m_DataSize]) if (m_SecurityToken != (SECURITY_TOKEN)(pPacket->m_aChunkData[pPacket->m_DataSize]))
{ {
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("security", "token mismatch, expected %d got %d", m_SecurityToken, *(SECURITY_TOKEN*)&pPacket->m_aChunkData[pPacket->m_DataSize]); dbg_msg("security", "token mismatch, expected %d got %d", m_SecurityToken, (SECURITY_TOKEN)(pPacket->m_aChunkData[pPacket->m_DataSize]));
return 0; return 0;
} }
} }
@ -278,7 +278,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
m_LastRecvTime = Now; m_LastRecvTime = Now;
m_LastUpdateTime = Now; m_LastUpdateTime = Now;
if (m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN if (m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN
&& pPacket->m_DataSize >= 1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken) && pPacket->m_DataSize >= (int)(1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken))
&& !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC))) && !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC)))
{ {
m_SecurityToken = SecurityToken; m_SecurityToken = SecurityToken;
@ -302,10 +302,10 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
if(CtrlMsg == NET_CTRLMSG_CONNECTACCEPT) if(CtrlMsg == NET_CTRLMSG_CONNECTACCEPT)
{ {
if (m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN if (m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN
&& pPacket->m_DataSize >= 1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken) && pPacket->m_DataSize >= (int)(1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken))
&& !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC))) && !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC)))
{ {
m_SecurityToken = *(SECURITY_TOKEN*)(&pPacket->m_aChunkData[1 + sizeof(SECURITY_TOKEN_MAGIC)]); m_SecurityToken = (SECURITY_TOKEN)*(&pPacket->m_aChunkData[1 + sizeof(SECURITY_TOKEN_MAGIC)]);
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("security", "got token %d", m_SecurityToken); dbg_msg("security", "got token %d", m_SecurityToken);
} }

View file

@ -201,7 +201,7 @@ int CNetServer::Recv(CNetChunk *pChunk)
md5_append(&md5, (unsigned char*)&Addr, sizeof(Addr)); md5_append(&md5, (unsigned char*)&Addr, sizeof(Addr));
md5_append(&md5, (unsigned char*)&timestamp, sizeof(timestamp)); md5_append(&md5, (unsigned char*)&timestamp, sizeof(timestamp));
md5_finish(&md5, digest); md5_finish(&md5, digest);
securityToken = *(SECURITY_TOKEN*)digest; securityToken = (SECURITY_TOKEN)*digest;
timestamp++; timestamp++;
} }
while (securityToken == NET_SECURITY_TOKEN_UNKNOWN || securityToken == NET_SECURITY_TOKEN_UNSUPPORTED); while (securityToken == NET_SECURITY_TOKEN_UNKNOWN || securityToken == NET_SECURITY_TOKEN_UNSUPPORTED);