From f0160fe7adec9eb35d19340e647edf07fc4cf9b2 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 27 Oct 2015 18:02:01 -0500 Subject: [PATCH] fix the warns that actually matter --- .../src/shared/ServerConsole.cpp | 7 ++-- .../library/sharedFoundation/src/linux/Os.cpp | 9 +++-- .../platform/projects/MonAPI2/MonitorAPI.cpp | 39 +++++++++---------- .../utils2.0/utils/Base/monitorAPI.cpp | 33 ++++++++-------- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/engine/server/application/ServerConsole/src/shared/ServerConsole.cpp b/engine/server/application/ServerConsole/src/shared/ServerConsole.cpp index 28a8a888..e3544fae 100644 --- a/engine/server/application/ServerConsole/src/shared/ServerConsole.cpp +++ b/engine/server/application/ServerConsole/src/shared/ServerConsole.cpp @@ -59,9 +59,10 @@ void ServerConsole::run() char inBuf[1024] = {"\0"}; while(! feof(stdin)) { - fread(inBuf, 1024, 1, stdin); - input += inBuf; - memset(inBuf, 0, sizeof(inBuf)); + if (fread(inBuf, 1024, 1, stdin)) { + input += inBuf; + memset(inBuf, 0, sizeof(inBuf)); + } } if(input.length() > 0) diff --git a/engine/shared/library/sharedFoundation/src/linux/Os.cpp b/engine/shared/library/sharedFoundation/src/linux/Os.cpp index 689957f3..2ddccf74 100644 --- a/engine/shared/library/sharedFoundation/src/linux/Os.cpp +++ b/engine/shared/library/sharedFoundation/src/linux/Os.cpp @@ -119,10 +119,11 @@ void Os::installCommon(void) char buffer[512]; while (!feof(f)) { - fgets(buffer, 512, f); - if (strncmp(buffer, "processor\t: ", 12)==0) - { - processorCount = atoi(buffer+12)+1; + if (fgets(buffer, 512, f) != NULL) { + if (strncmp(buffer, "processor\t: ", 12)==0) + { + processorCount = atoi(buffer+12)+1; + } } } fclose(f); diff --git a/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp b/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp index 8abd18a9..78d7d1a2 100644 --- a/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp +++ b/external/3rd/library/platform/projects/MonAPI2/MonitorAPI.cpp @@ -370,28 +370,27 @@ char buffer[1024]; x = 0; while(!feof(fp)) { - fgets( buffer, 1023, fp); - - // get rid of '\n' and '\r' for comparisons - strtok(buffer,"\r\n"); - len = (int)strlen(buffer); - if( len > 0 ) - { - if( nline == 0 ) + if (fgets( buffer, 1023, fp) != NULL) { + // get rid of '\n' and '\r' for comparisons + strtok(buffer,"\r\n"); + len = (int)strlen(buffer); + if( len > 0 ) { - passString = (char *)malloc( len + 1 ); - strcpy(passString,buffer); + if( nline == 0 ) + { + passString = (char *)malloc( len + 1 ); + strcpy(passString,buffer); + } + else + { + allowedAddressList[x] = (char *)malloc( len + 1 ); + strcpy(allowedAddressList[x],buffer); + x++; + } } - else - { - allowedAddressList[x] = (char *)malloc( len + 1 ); - strcpy(allowedAddressList[x],buffer); - x++; - } - } - nline++; - } - + nline++; + } + } // clean up fclose(fp); return true; diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp index aac02947..e11e4bcc 100644 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/monitorAPI.cpp @@ -367,26 +367,27 @@ char buffer[1024]; x = 0; while(!feof(fp)) { - fgets( buffer, 1023, fp); + if (fgets( buffer, 1023, fp) != NULL) { - // get rid of '\n' and '\r' for comparisons - strtok(buffer,"\r\n"); - len = strlen(buffer); - if( len > 0 ) - { - if( nline == 0 ) + // get rid of '\n' and '\r' for comparisons + strtok(buffer,"\r\n"); + len = strlen(buffer); + if( len > 0 ) { - passString = (char *)malloc( len + 1 ); - strcpy(passString,buffer); - } - else - { - allowedAddressList[x] = (char *)malloc( len + 1 ); - strcpy(allowedAddressList[x],buffer); - x++; + if( nline == 0 ) + { + passString = (char *)malloc( len + 1 ); + strcpy(passString,buffer); + } + else + { + allowedAddressList[x] = (char *)malloc( len + 1 ); + strcpy(allowedAddressList[x],buffer); + x++; + } } + nline++; } - nline++; } // clean up