diff --git a/ambed/Makefile b/ambed/Makefile index b2dfdbe..d9c0547 100644 --- a/ambed/Makefile +++ b/ambed/Makefile @@ -13,9 +13,9 @@ GCC = g++ ifeq ($(debug), true) -CFLAGS = -ggdb3 -W -MMD -MD -std=c++11 +CFLAGS = -ggdb3 -W -Werror -MMD -MD -std=c++11 else -CFLAGS = -W -MMD -MD -std=c++11 +CFLAGS = -W -Werror -MMD -MD -std=c++11 endif LDFLAGS = -pthread diff --git a/ambed/ccallsign.cpp b/ambed/ccallsign.cpp index a9cf00f..ef876c1 100644 --- a/ambed/ccallsign.cpp +++ b/ambed/ccallsign.cpp @@ -87,7 +87,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len) { // set callsign ::memset(m_Callsign, ' ', sizeof(m_Callsign)); - ::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign))); + ::memcpy(m_Callsign, buffer, MIN(len, (int)sizeof(m_Callsign))); for ( unsigned i = 0; i < sizeof(m_Callsign); i++ ) { if ( m_Callsign[i] == 0 ) @@ -105,7 +105,7 @@ void CCallsign::PatchCallsign(int off, const uint8 *patch, int len) { if ( off < int(sizeof(m_Callsign)) ) { - ::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off)); + ::memcpy(m_Callsign, patch, MIN(len, (int)sizeof(m_Callsign) - off)); } } diff --git a/ambed/cvoicepacket.cpp b/ambed/cvoicepacket.cpp index d62faed..fe91345 100644 --- a/ambed/cvoicepacket.cpp +++ b/ambed/cvoicepacket.cpp @@ -39,7 +39,7 @@ CVoicePacket::CVoicePacket() CVoicePacket::CVoicePacket(const uint8 *voice, int size) { - m_iSize = MIN(size, sizeof(m_uiVoice)); + m_iSize = MIN(size, (int)sizeof(m_uiVoice)); ::memset(m_uiVoice, 0, sizeof(m_uiVoice)); ::memcpy(m_uiVoice, voice, m_iSize); } @@ -64,8 +64,7 @@ CVoicePacket::~CVoicePacket() void CVoicePacket::SetVoice(const uint8 *voice, int size) { - m_iSize = MIN(size, sizeof(m_uiVoice)); + m_iSize = MIN(size, (int)sizeof(m_uiVoice)); ::memset(m_uiVoice, 0, sizeof(m_uiVoice)); ::memcpy(m_uiVoice, voice, m_iSize); } - diff --git a/ambed/main.h b/ambed/main.h index b88da3f..09b501b 100644 --- a/ambed/main.h +++ b/ambed/main.h @@ -94,8 +94,8 @@ typedef unsigned int uint; //////////////////////////////////////////////////////////////////////////////////////// // macros -#define MIN(a,b) (int(a) < int(b))?(a):(b) -#define MAX(a,b) (int(a) > int(b))?(a):(b) +#define MIN(a,b) ((a)<(b))?(a):(b) +#define MAX(a,b) ((a)>(b))?(a):(b) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) diff --git a/src/Makefile b/src/Makefile index 8367b16..a61a1d1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -29,9 +29,9 @@ DATADIR = /var/lib/xlxd CC = g++ ifeq ($(debug), true) -CFLAGS = -ggdb3 -W -c -std=c++11 -MMD -MD -c +CFLAGS = -ggdb3 -W -Werror -c -std=c++11 -MMD -MD -c else -CFLAGS = -c -W -std=c++11 -MMD -MD -c +CFLAGS = -c -W -Werror -std=c++11 -MMD -MD -c endif LDFLAGS=-pthread diff --git a/src/ccallsign.cpp b/src/ccallsign.cpp index 77f5a58..55cc323 100644 --- a/src/ccallsign.cpp +++ b/src/ccallsign.cpp @@ -173,7 +173,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid) // set callsign ::memset(m_Callsign, ' ', sizeof(m_Callsign)); m_Module = ' '; - ::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign)-1)); + ::memcpy(m_Callsign, buffer, MIN(len, (int)sizeof(m_Callsign)-1)); for ( unsigned i = 0; i < sizeof(m_Callsign); i++ ) { if ( m_Callsign[i] == 0 ) @@ -238,7 +238,7 @@ void CCallsign::SetSuffix(const char *sz) void CCallsign::SetSuffix(const uint8 *buffer, int len) { - len = MIN(len, sizeof(m_Suffix)); + len = MIN(len, (int)sizeof(m_Suffix)); ::memset(m_Suffix, ' ', sizeof(m_Suffix)); ::memcpy(m_Suffix, buffer, len); } @@ -250,7 +250,7 @@ void CCallsign::PatchCallsign(int off, const uint8 *patch, int len) { if ( off < CALLSIGN_LEN ) { - ::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off)); + ::memcpy(m_Callsign, patch, MIN(len, (int)sizeof(m_Callsign) - off)); } } diff --git a/src/ccallsignlistitem.cpp b/src/ccallsignlistitem.cpp index 85a8b62..f984bdc 100644 --- a/src/ccallsignlistitem.cpp +++ b/src/ccallsignlistitem.cpp @@ -52,7 +52,7 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, c } else { - int n = MIN((int)::strlen(modules), sizeof(m_Modules)-1); + int n = MIN(::strlen(modules), sizeof(m_Modules)-1); int j = 0; for ( int i = 0; i < n; i++ ) { @@ -82,7 +82,7 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const char *url, } else { - int n = MIN((int)::strlen(modules), sizeof(m_Modules)-1); + int n = MIN(::strlen(modules), sizeof(m_Modules)-1); int j = 0; for ( int i = 0; i < n; i++ ) { diff --git a/src/main.h b/src/main.h index b7ff5bb..8ea8210 100644 --- a/src/main.h +++ b/src/main.h @@ -221,8 +221,8 @@ typedef unsigned int uint; //////////////////////////////////////////////////////////////////////////////////////// // macros -#define MIN(a,b) (int(a) < int(b))?(a):(b) -#define MAX(a,b) (int(a) > int(b))?(a):(b) +#define MIN(a,b) ((a)<(b))?(a):(b) +#define MAX(a,b) ((a)>(b))?(a):(b) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF))