MIN MAX macro fix

pull/6/head
Tom Early 4 years ago
parent 7ebf6dc3cd
commit 649e662738

@ -13,9 +13,9 @@ GCC = g++
ifeq ($(debug), true) ifeq ($(debug), true)
CFLAGS = -ggdb3 -W -MMD -MD -std=c++11 CFLAGS = -ggdb3 -W -Werror -MMD -MD -std=c++11
else else
CFLAGS = -W -MMD -MD -std=c++11 CFLAGS = -W -Werror -MMD -MD -std=c++11
endif endif
LDFLAGS = -pthread LDFLAGS = -pthread

@ -87,7 +87,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len)
{ {
// set callsign // set callsign
::memset(m_Callsign, ' ', sizeof(m_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++ ) for ( unsigned i = 0; i < sizeof(m_Callsign); i++ )
{ {
if ( m_Callsign[i] == 0 ) 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)) ) 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));
} }
} }

@ -39,7 +39,7 @@ CVoicePacket::CVoicePacket()
CVoicePacket::CVoicePacket(const uint8 *voice, int size) 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)); ::memset(m_uiVoice, 0, sizeof(m_uiVoice));
::memcpy(m_uiVoice, voice, m_iSize); ::memcpy(m_uiVoice, voice, m_iSize);
} }
@ -64,8 +64,7 @@ CVoicePacket::~CVoicePacket()
void CVoicePacket::SetVoice(const uint8 *voice, int size) 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)); ::memset(m_uiVoice, 0, sizeof(m_uiVoice));
::memcpy(m_uiVoice, voice, m_iSize); ::memcpy(m_uiVoice, voice, m_iSize);
} }

@ -94,8 +94,8 @@ typedef unsigned int uint;
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
#define MIN(a,b) (int(a) < int(b))?(a):(b) #define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) (int(a) > int(b))?(a):(b) #define MAX(a,b) ((a)>(b))?(a):(b)
#define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8)))
#define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16)))
#define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF))

@ -29,9 +29,9 @@ DATADIR = /var/lib/xlxd
CC = g++ CC = g++
ifeq ($(debug), true) 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 else
CFLAGS = -c -W -std=c++11 -MMD -MD -c CFLAGS = -c -W -Werror -std=c++11 -MMD -MD -c
endif endif
LDFLAGS=-pthread LDFLAGS=-pthread

@ -173,7 +173,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
// set callsign // set callsign
::memset(m_Callsign, ' ', sizeof(m_Callsign)); ::memset(m_Callsign, ' ', sizeof(m_Callsign));
m_Module = ' '; 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++ ) for ( unsigned i = 0; i < sizeof(m_Callsign); i++ )
{ {
if ( m_Callsign[i] == 0 ) if ( m_Callsign[i] == 0 )
@ -238,7 +238,7 @@ void CCallsign::SetSuffix(const char *sz)
void CCallsign::SetSuffix(const uint8 *buffer, int len) 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)); ::memset(m_Suffix, ' ', sizeof(m_Suffix));
::memcpy(m_Suffix, buffer, len); ::memcpy(m_Suffix, buffer, len);
} }
@ -250,7 +250,7 @@ void CCallsign::PatchCallsign(int off, const uint8 *patch, int len)
{ {
if ( off < CALLSIGN_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));
} }
} }

@ -52,7 +52,7 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, c
} }
else else
{ {
int n = MIN((int)::strlen(modules), sizeof(m_Modules)-1); int n = MIN(::strlen(modules), sizeof(m_Modules)-1);
int j = 0; int j = 0;
for ( int i = 0; i < n; i++ ) for ( int i = 0; i < n; i++ )
{ {
@ -82,7 +82,7 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const char *url,
} }
else else
{ {
int n = MIN((int)::strlen(modules), sizeof(m_Modules)-1); int n = MIN(::strlen(modules), sizeof(m_Modules)-1);
int j = 0; int j = 0;
for ( int i = 0; i < n; i++ ) for ( int i = 0; i < n; i++ )
{ {

@ -221,8 +221,8 @@ typedef unsigned int uint;
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
#define MIN(a,b) (int(a) < int(b))?(a):(b) #define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) (int(a) > int(b))?(a):(b) #define MAX(a,b) ((a)>(b))?(a):(b)
#define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8)))
#define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16)))
#define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF))

Loading…
Cancel
Save

Powered by TurnKey Linux.