mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 19:29:47 +02:00
a bunch more code cleanup from cppcheck
This commit is contained in:
@@ -103,7 +103,7 @@ int zipfile_tool(int argc, const char *argv[]) {
|
||||
pSrc_filename = argv[p++];
|
||||
pDst_filename = argv[p++];
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED)printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED)printf("Mode: %c, Level: %d\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
||||
|
||||
// Open input file.
|
||||
pInfile = fopen(pSrc_filename, "rb");
|
||||
|
@@ -84,7 +84,7 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
||||
|
||||
GLenum error = glGetError();
|
||||
if(error != GL_NO_ERROR) {
|
||||
printf("\n[%s::%s] Line %d Error = %d [%s] for size = %d res = %d\n",__FILE__,__FUNCTION__,__LINE__,error,gluErrorString(error),defSize,TextFTGL::faceResolution);
|
||||
printf("\n[%s::%s] Line %d Error = %d [%s] for size = %u res = %d\n",__FILE__,__FUNCTION__,__LINE__,error,gluErrorString(error),defSize,TextFTGL::faceResolution);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
@@ -551,7 +551,7 @@ bool VideoPlayer::initPlayer(string mediaURL) {
|
||||
#if defined(WIN32)
|
||||
if(verboseEnabled) _putenv("VLC_VERBOSE=2");
|
||||
#endif
|
||||
int vlc_argc = ctxPtr->vlc_argv.size();
|
||||
|
||||
|
||||
// char const *vlc_argv[] =
|
||||
// {
|
||||
@@ -591,6 +591,7 @@ bool VideoPlayer::initPlayer(string mediaURL) {
|
||||
ctxPtr->libvlc = libvlc_new(ctxPtr->vlc_argc, &ctxPtr->vlc_argv[0],&ex);
|
||||
catchError(&ex);
|
||||
#else
|
||||
int vlc_argc = ctxPtr->vlc_argv.size();
|
||||
ctxPtr->libvlc = libvlc_new(vlc_argc, &ctxPtr->vlc_argv[0]);
|
||||
#endif
|
||||
|
||||
@@ -1322,8 +1323,9 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
|
||||
ctxPtr != NULL && ctxPtr->isPlaying == true &&
|
||||
finished == false && stop == false) {
|
||||
|
||||
int action = 0, pause = 0, n = 0;
|
||||
action = 0;
|
||||
//int action = 0, pause = 0, n = 0;
|
||||
//int action = 0, n = 0;
|
||||
int action = 0;
|
||||
|
||||
SDL_Event event;
|
||||
/* Keys: enter (fullscreen), space (pause), escape (quit) */
|
||||
@@ -1353,14 +1355,14 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
|
||||
//screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);
|
||||
finished = true;
|
||||
break;
|
||||
case ' ':
|
||||
//pause = !pause;
|
||||
break;
|
||||
//case ' ':
|
||||
// //pause = !pause;
|
||||
// break;
|
||||
}
|
||||
|
||||
if(pause == 0) {
|
||||
n++;
|
||||
}
|
||||
//if(pause == 0) {
|
||||
//n++;
|
||||
//}
|
||||
|
||||
//assertGl();
|
||||
|
||||
|
@@ -504,9 +504,8 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori
|
||||
#endif
|
||||
|
||||
bool IRCThread::getEventDataDone() {
|
||||
bool result = false;
|
||||
MutexSafeWrapper safeMutex(&mutexEventDataDone,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
result = eventDataDone;
|
||||
bool result = eventDataDone;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return result;
|
||||
|
@@ -598,7 +598,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||
|
||||
// Now lookup the appropriate adaptor-name in the pAdaptorInfos, if we can find it
|
||||
const char * name = NULL;
|
||||
const char * desc = NULL;
|
||||
//const char * desc = NULL;
|
||||
if (pAdapterInfo)
|
||||
{
|
||||
IP_ADAPTER_INFO * next = pAdapterInfo;
|
||||
@@ -610,7 +610,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||
if (Inet_AtoN(ipAddr->IpAddress.String) == ntohl(row.dwAddr))
|
||||
{
|
||||
name = next->AdapterName;
|
||||
desc = next->Description;
|
||||
//desc = next->Description;
|
||||
break;
|
||||
}
|
||||
ipAddr = ipAddr->Next;
|
||||
@@ -1361,8 +1361,6 @@ int Socket::send(const void *data, int dataSize) {
|
||||
}
|
||||
|
||||
int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
|
||||
const int MAX_RECV_WAIT_SECONDS = 3;
|
||||
|
||||
ssize_t bytesReceived = 0;
|
||||
|
||||
if(isSocketValid() == true) {
|
||||
@@ -1387,6 +1385,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
|
||||
else if(bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
const int MAX_RECV_WAIT_SECONDS = 3;
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
|
||||
(difftime((long int)time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) {
|
||||
@@ -1480,8 +1479,6 @@ int Socket::peek(void *data, int dataSize,bool mustGetData,int *pLastSocketError
|
||||
Chrono chrono;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) chrono.start();
|
||||
|
||||
const int MAX_PEEK_WAIT_SECONDS = 3;
|
||||
|
||||
int lastSocketError = 0;
|
||||
int err = 0;
|
||||
if(isSocketValid() == true) {
|
||||
@@ -1539,6 +1536,7 @@ int Socket::peek(void *data, int dataSize,bool mustGetData,int *pLastSocketError
|
||||
|
||||
//printf("Peek #2 err = %d\n",err);
|
||||
|
||||
const int MAX_PEEK_WAIT_SECONDS = 3;
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
|
||||
isSocketValid() == true &&
|
||||
@@ -2033,7 +2031,6 @@ void BroadCastClientSocketThread::execute() {
|
||||
struct sockaddr_in bcaddr; // The broadcast address for the receiver.
|
||||
PLATFORM_SOCKET bcfd; // The file descriptor used for the broadcast.
|
||||
//bool one = true; // Parameter for "setscokopt".
|
||||
char buff[10024]=""; // Buffers the data to be broadcasted.
|
||||
socklen_t alen=0;
|
||||
|
||||
port = htons( Socket::getBroadCastPort() );
|
||||
@@ -2067,6 +2064,7 @@ void BroadCastClientSocketThread::execute() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
try {
|
||||
char buff[10024]=""; // Buffers the data to be broadcasted.
|
||||
// Keep getting packets forever.
|
||||
for( time_t elapsed = time(NULL); difftime((long int)time(NULL),elapsed) <= 5; ) {
|
||||
alen = sizeof(struct sockaddr);
|
||||
@@ -2515,7 +2513,6 @@ int UPNP_Tools::upnp_init(void *param) {
|
||||
int result = -1;
|
||||
struct UPNPDev *devlist = NULL;
|
||||
struct UPNPDev *dev = NULL;
|
||||
char *descXML = NULL;
|
||||
int descXMLsize = 0;
|
||||
char buf[255] = "";
|
||||
// Callers MUST pass in NULL or a UPNPInitInterface *
|
||||
@@ -2575,9 +2572,9 @@ int UPNP_Tools::upnp_init(void *param) {
|
||||
|
||||
//printf("UPnP device found: [%s] [%s] lanaddr [%s]\n", dev->descURL, dev->st,lanaddr);
|
||||
#if !defined(MINIUPNPC_VERSION_PRE1_7) && !defined(MINIUPNPC_VERSION_PRE1_6)
|
||||
descXML = (char *)miniwget_getaddr(dev->descURL, &descXMLsize, lanaddr, (sizeof(lanaddr) / sizeof(lanaddr[0])),0);
|
||||
char *descXML = (char *)miniwget_getaddr(dev->descURL, &descXMLsize, lanaddr, (sizeof(lanaddr) / sizeof(lanaddr[0])),0);
|
||||
#else
|
||||
descXML = (char *)miniwget_getaddr(dev->descURL, &descXMLsize, lanaddr, (sizeof(lanaddr) / sizeof(lanaddr[0])));
|
||||
char *descXML = (char *)miniwget_getaddr(dev->descURL, &descXMLsize, lanaddr, (sizeof(lanaddr) / sizeof(lanaddr[0])));
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"LAN address: %s\n", lanaddr);
|
||||
|
||||
@@ -2656,9 +2653,6 @@ int UPNP_Tools::upnp_init(void *param) {
|
||||
|
||||
bool UPNP_Tools::upnp_add_redirect(int ports[2],bool mutexLock) {
|
||||
bool result = true;
|
||||
char externalIP[16] = "";
|
||||
char ext_port_str[16] = "";
|
||||
char int_port_str[16] = "";
|
||||
|
||||
//printf("SERVER SOCKET upnp_add_redirect - START\n");
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] upnp_add_redir(%d : %d)\n",__FILE__,__FUNCTION__,__LINE__,ports[0],ports[1]);
|
||||
@@ -2679,12 +2673,15 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2],bool mutexLock) {
|
||||
result = false;
|
||||
}
|
||||
else {
|
||||
char externalIP[16] = "";
|
||||
#ifndef MINIUPNPC_VERSION_PRE1_5
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
|
||||
#else
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
|
||||
#endif
|
||||
|
||||
char ext_port_str[16] = "";
|
||||
char int_port_str[16] = "";
|
||||
sprintf(ext_port_str, "%d", ports[0]);
|
||||
sprintf(int_port_str, "%d", ports[1]);
|
||||
|
||||
|
@@ -632,7 +632,6 @@ void Window::toggleFullscreen() {
|
||||
|
||||
void Window::handleMouseDown(SDL_Event event) {
|
||||
static const Uint32 DOUBLECLICKTIME = 500;
|
||||
static const int DOUBLECLICKDELTA = 5;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -663,6 +662,7 @@ void Window::handleMouseDown(SDL_Event event) {
|
||||
if(n >= 0 && n < mbCount) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
static const int DOUBLECLICKDELTA = 5;
|
||||
if(ticks - lastMouseDown[n] < DOUBLECLICKTIME
|
||||
&& abs(lastMouseX[n] - event.button.x) < DOUBLECLICKDELTA
|
||||
&& abs(lastMouseY[n] - event.button.y) < DOUBLECLICKDELTA) {
|
||||
@@ -944,7 +944,7 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
|
||||
@@ -1010,7 +1010,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
|
||||
@@ -1177,7 +1177,7 @@ wchar_t Window::extractLastKeyPressed() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string inputKeyName = SDL_GetKeyName(keystate.sym);
|
||||
//string inputKeyName = SDL_GetKeyName(keystate.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
|
||||
|
@@ -261,7 +261,6 @@ bool Checksum::addFileToSum(const string &path) {
|
||||
addString(lastFile(path));
|
||||
|
||||
bool isXMLFile = (EndsWith(path, ".xml") == true);
|
||||
bool inCommentTag=false;
|
||||
|
||||
// Determine the file length
|
||||
ifs.seekg(0, ios::end);
|
||||
@@ -277,6 +276,7 @@ bool Checksum::addFileToSum(const string &path) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] buf.size() = %d, path [%s], isXMLFile = %d\n",__FILE__,__FUNCTION__,__LINE__,buf.size(), path.c_str(),isXMLFile);
|
||||
|
||||
if(isXMLFile == true) {
|
||||
bool inCommentTag=false;
|
||||
for(std::size_t i = 0; i < buf.size(); ++i) {
|
||||
// Ignore Spaces in XML files as they are
|
||||
// ONLY for formatting
|
||||
@@ -343,7 +343,8 @@ uint32 Checksum::getSum() {
|
||||
MutexSafeWrapper safeMutexSocketDestructorFlag(&Checksum::fileListCacheSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {
|
||||
Checksum fileResult;
|
||||
bool fileAddedOk = fileResult.addFileToSum(iterMap->first);
|
||||
//bool fileAddedOk = fileResult.addFileToSum(iterMap->first);
|
||||
fileResult.addFileToSum(iterMap->first);
|
||||
Checksum::fileListCache[iterMap->first] = fileResult.getSum();
|
||||
//printf("fileAddedOk = %d for file [%s] CRC [%d]\n",fileAddedOk,iterMap->first.c_str(),Checksum::fileListCache[iterMap->first]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user