From 22d206b1db5be1f9945d95b6bed54209696fbdfe Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 1 Aug 2010 10:39:41 +0200 Subject: [PATCH] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/src/3d/skeleton_model.cpp | 1 + code/nel/src/misc/async_file_manager.cpp | 6 ++-- code/nel/src/misc/common.cpp | 11 ++++++-- code/nel/src/misc/cpu_time_stat.cpp | 8 +++--- code/nel/src/misc/eid_translator.cpp | 3 +- code/nel/src/misc/path.cpp | 36 ++++++++++++++++++++---- code/nel/src/misc/system_info.cpp | 4 ++- 7 files changed, 53 insertions(+), 16 deletions(-) diff --git a/code/nel/src/3d/skeleton_model.cpp b/code/nel/src/3d/skeleton_model.cpp index f21a67b42..527a6c815 100644 --- a/code/nel/src/3d/skeleton_model.cpp +++ b/code/nel/src/3d/skeleton_model.cpp @@ -1384,6 +1384,7 @@ void CSkeletonModel::renderCLod() CRGBA plDiffuse; // get the diffuse of the pointLight, attenuated from distance and importance. plDiffuse.modulateFromuiRGBOnly(mainPL->getDiffuse(), lightContrib->AttFactor[0]); + plDiffuse.A = 255; // compare the 2 diffuse uint d0= mainDiffuse.R + mainDiffuse.G + mainDiffuse.B; uint d1= plDiffuse.R + plDiffuse.G + plDiffuse.B; diff --git a/code/nel/src/misc/async_file_manager.cpp b/code/nel/src/misc/async_file_manager.cpp index e7b2bd072..878ddfd60 100644 --- a/code/nel/src/misc/async_file_manager.cpp +++ b/code/nel/src/misc/async_file_manager.cpp @@ -213,7 +213,8 @@ void CAsyncFileManager::CFileLoad::run (void) //nlSleep(5); //fseek (f, 0, SEEK_SET); ptr = new uint8[filesize]; - fread (ptr, filesize, 1, f); + if (fread (ptr, filesize, 1, f) != 1) + nlwarning("AFM: Couldn't read '%s'", _FileName.c_str()); fclose (f); *_ppFile = ptr; @@ -258,7 +259,8 @@ void CAsyncFileManager::CMultipleFileLoad::run (void) //nlSleep(5); //fseek (f, 0, SEEK_SET); ptr = new uint8[filesize]; - fread (ptr, filesize, 1, f); + if (fread (ptr, filesize, 1, f) != 1) + nlwarning("AFM: Couldn't read '%s'", _FileName[i].c_str()); fclose (f); *_Ptrs[i] = ptr; diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 59ac2dad2..643b30599 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -875,8 +875,15 @@ NLMISC_CATEGORISED_COMMAND(nel, system, "Execute the command line using system() string cmd = args[0]; log.displayNL ("Executing '%s'", cmd.c_str()); - system(cmd.c_str()); - log.displayNL ("End of Execution of '%s'", cmd.c_str()); + sint error = system(cmd.c_str()); + if (error) + { + log.displayNL ("Execution of '%s' failed with error code %d", cmd.c_str(), error); + } + else + { + log.displayNL ("End of Execution of '%s'", cmd.c_str()); + } return true; } diff --git a/code/nel/src/misc/cpu_time_stat.cpp b/code/nel/src/misc/cpu_time_stat.cpp index dc99a64cf..b067803d7 100644 --- a/code/nel/src/misc/cpu_time_stat.cpp +++ b/code/nel/src/misc/cpu_time_stat.cpp @@ -44,7 +44,8 @@ bool CCPUTimeStat::getCPUTicks(uint64& user, uint64& nice, uint64& system, uint6 // /proc/stat // cpu [user] [nice] [system] [idle] [iowait] [irq] [softirq] - fscanf(f, "cpu %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &user, &nice, &system, &idle, &iowait); + if (fscanf(f, "cpu %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &user, &nice, &system, &idle, &iowait) != 5) + nlwarning("Failed to parse /proc/stat"); fclose(f); @@ -54,8 +55,6 @@ bool CCPUTimeStat::getCPUTicks(uint64& user, uint64& nice, uint64& system, uint6 #endif } - - // Get absolute ticks values for a specified pid bool CCPUTimeStat::getPIDTicks(uint64& utime, uint64& stime, uint64& cutime, uint64& cstime, uint pid) { @@ -69,7 +68,8 @@ bool CCPUTimeStat::getPIDTicks(uint64& utime, uint64& stime, uint64& cutime, uin // /proc//stat // pid com sta ppi pgi ses tty tpg fla mif maf cmi cma [utime] [stime] [cutime] [cstime] ... - fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &utime, &stime, &cutime, &cstime); + if (fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &utime, &stime, &cutime, &cstime) != 4) + nlwarning("Failed to parse /proc//stat"); fclose(f); diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index a8914456e..c5b1bcff8 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -440,7 +440,8 @@ void cbInvalidEntityNamesFilename(const std::string &invalidEntityNamesFilename) for(;;) { char str[512]; - fgets(str, 511, fp); + if (fgets(str, 511, fp) == NULL) + break; if(feof(fp)) break; if (strlen(str) > 0) diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 5f445f23d..01e0404d0 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1217,10 +1217,18 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, //uint32 nFileSize = ftell (Handle); nlfseek64 (Handle, nFileSize-4, SEEK_SET); uint32 nOffsetFromBegining; - fread (&nOffsetFromBegining, sizeof(uint32), 1, Handle); + if (fread (&nOffsetFromBegining, sizeof(uint32), 1, Handle) != 1) + { + fclose(Handle); + return; + } nlfseek64 (Handle, nOffsetFromBegining, SEEK_SET); uint32 nNbFile; - fread (&nNbFile, sizeof(uint32), 1, Handle); + if (fread (&nNbFile, sizeof(uint32), 1, Handle) != 1) + { + fclose(Handle); + return; + } for (uint32 i = 0; i < nNbFile; ++i) { // Progress bar @@ -1232,13 +1240,29 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, char FileName[256]; uint8 nStringSize; - fread (&nStringSize, 1, 1, Handle); - fread (FileName, 1, nStringSize, Handle); + if (fread (&nStringSize, 1, 1, Handle) != 1) + { + fclose(Handle); + return; + } + if (fread (FileName, 1, nStringSize, Handle) != nStringSize) + { + fclose(Handle); + return; + } FileName[nStringSize] = 0; uint32 nFileSize2; - fread (&nFileSize2, sizeof(uint32), 1, Handle); + if (fread (&nFileSize2, sizeof(uint32), 1, Handle) != 1) + { + fclose(Handle); + return; + } uint32 nFilePos; - fread (&nFilePos, sizeof(uint32), 1, Handle); + if (fread (&nFilePos, sizeof(uint32), 1, Handle) != 1) + { + fclose(Handle); + return; + } string sTmp = toLower(string(FileName)); if (sTmp.empty()) { diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 446b39320..97397f001 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -1085,7 +1085,9 @@ string CSystemInfo::availableHDSpace (const string &filename) else cmd += filename; cmd += " >/tmp/nelhdfs"; - (void) system (cmd.c_str()); + sint error = system (cmd.c_str()); + if (error) + nlwarning("'%s' failed with error code %d", cmd.c_str(), error); int fd = open("/tmp/nelhdfs", O_RDONLY); if (fd == -1)