diff --git a/code/nel/samples/3d/cluster_viewer/main.cpp b/code/nel/samples/3d/cluster_viewer/main.cpp index 431d9c2f6..7ca5b07a1 100644 --- a/code/nel/samples/3d/cluster_viewer/main.cpp +++ b/code/nel/samples/3d/cluster_viewer/main.cpp @@ -209,7 +209,6 @@ int main() double rGlobalTime = 0; double rOldGlobalTime = 0; double rDeltaTime = 0; - double rMoveTime = 0; vector DispCS; @@ -430,7 +429,7 @@ int main() { nSelected--; if(nSelected == -1) - nSelected = DispCS.size()-1; + nSelected = (sint32)DispCS.size()-1; } if (CNELU::AsyncListener.isKeyPushed (KeyS)) { diff --git a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp index b116ebad1..0914c483d 100644 --- a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp +++ b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp @@ -92,7 +92,7 @@ void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig) nlassert(m_Driver); // initialize the window with config file values - m_Driver->setDisplay((void *)winId(), NL3D::UDriver::CMode(width(), height(), 32)); + m_Driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32)); // register config callbacks connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), diff --git a/code/nel/samples/misc/configfile/main.cpp b/code/nel/samples/misc/configfile/main.cpp index 77a3a859f..f5a3fd472 100644 --- a/code/nel/samples/misc/configfile/main.cpp +++ b/code/nel/samples/misc/configfile/main.cpp @@ -58,7 +58,7 @@ void var12Callback (CConfigFile::CVar &var) // the configfile CConfigFile cf; -int main (int argc, char **argv) +int main (int /* argc */, char ** /* argv */) { // look at the debug example @@ -87,14 +87,17 @@ int main (int argc, char **argv) // get the value of var1 as int int var1 = cf.getVar ("var1").asInt(); + nlinfo("var1 (int) = %d", var1); // get the value of var1 as double, in this case, a conversion from int // to double will be done double var2 = cf.getVar ("var1").asDouble(); + nlinfo("var1 (double) = %lf", var2); // get the value of var2 as int, in this case, a conversion from string // to int will be done int var3 = cf.getVar ("var2").asInt(); + nlinfo("var2 = %d", var3); // if the variable is an array of values, you can access them putting the // index of the variable you want. Example, get and print all value of var12: @@ -111,6 +114,7 @@ int main (int argc, char **argv) { // try to access an unknown variable int val = cf.getVar ("unknown_variable").asInt(); + nlinfo("unknown_variable = %d", val); } catch (EConfigFile &e) { diff --git a/code/nel/samples/misc/debug/main.cpp b/code/nel/samples/misc/debug/main.cpp index 347f01fbc..9d17d158c 100644 --- a/code/nel/samples/misc/debug/main.cpp +++ b/code/nel/samples/misc/debug/main.cpp @@ -22,7 +22,7 @@ using namespace NLMISC; -int main (int argc, char **argv) +int main (int /* argc */, char ** /* argv */) { // all debug functions have different behaviors in debug and in release mode. // in general, in debug mode, all debug functions are active, they display diff --git a/code/nel/samples/misc/log/main.cpp b/code/nel/samples/misc/log/main.cpp index 78b6a10b9..76d4fce95 100644 --- a/code/nel/samples/misc/log/main.cpp +++ b/code/nel/samples/misc/log/main.cpp @@ -40,7 +40,7 @@ CFileDisplayer fd("main.log",true); // Windows, it does nothing on other systems. CMsgBoxDisplayer mbd; -int main (int argc, char **argv) +int main (int /* argc */, char ** /* argv */) { // create a logger; it's an information logger. CLog logger (CLog::LOG_INFO); diff --git a/code/nel/samples/net/chat/kbhit.cpp b/code/nel/samples/net/chat/kbhit.cpp index 50c8f2c65..261b203e9 100644 --- a/code/nel/samples/net/chat/kbhit.cpp +++ b/code/nel/samples/net/chat/kbhit.cpp @@ -71,7 +71,8 @@ int getch() peek_character = -1; return ch; } - read(STDIN_FILENO,&ch,1); + if (read(STDIN_FILENO,&ch,1) != 1) + nlwarning("Can't read keyboard"); return ch; } diff --git a/code/nel/samples/net/login_system/client.cpp b/code/nel/samples/net/login_system/client.cpp index 532b1a22c..408baea65 100644 --- a/code/nel/samples/net/login_system/client.cpp +++ b/code/nel/samples/net/login_system/client.cpp @@ -117,8 +117,11 @@ int main (int argc, char **argv) sint32 sid = ConfigFile.getVar("ShardId").asInt(); if(sid == 0) { - printf("Enter the SharId you want to connect to: "); - scanf("%d", sid); + printf("Enter the ShardId you want to connect to: "); + if (scanf("%d", &sid) != 1) + { + nlwarning("Can't parse ShardId"); + } } /* Try to connect to the shard number 0 in the list. diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index f76433ea8..dc631f80c 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -196,7 +196,7 @@ void cbInit (CMessage &msgin, TSockId from, CCallbackNetBase &netbase) msgout.serial (session); CallbackServer->send (msgout, from); - Clients.push_back(CClient(from, session, connectionName)); + Clients.push_back(CClient(from, (uint32)session, connectionName)); nlinfo ("Added client TCP %s, session %x", from->asString().c_str(), session); } @@ -517,7 +517,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime) memcpy (msgin.bufferToFill (currentsize), CurrentInMsg->userDataR(), currentsize); // Read the header - uint8 mode; + uint8 mode = 0; msgin.serial (mode); if (mode == 0) diff --git a/code/nel/samples/net/udp/client.cpp b/code/nel/samples/net/udp/client.cpp index 9079d8109..51ed287ce 100644 --- a/code/nel/samples/net/udp/client.cpp +++ b/code/nel/samples/net/udp/client.cpp @@ -380,13 +380,13 @@ int main( int argc, char **argv ) CMemStream msgin( true ); memcpy (msgin.bufferToFill (psize), packet, psize); - sint64 t; + sint64 t = 0; msgin.serial (t); - uint32 p; + uint32 p = 0; msgin.serial (p); - uint32 b; + uint32 b = 0; msgin.serial (b); // I received a ping, send a pong diff --git a/code/nel/samples/pacs/main.cpp b/code/nel/samples/pacs/main.cpp index b04a743db..256acf9b3 100644 --- a/code/nel/samples/pacs/main.cpp +++ b/code/nel/samples/pacs/main.cpp @@ -376,7 +376,7 @@ int main () #ifdef NL_OS_WINDOWS ::MessageBox (NULL, e.what(), "Test collision move", MB_OK|MB_ICONEXCLAMATION); #else // NL_OS_WINDOWS - printf (e.what()); + printf ("%s\n", e.what()); #endif // NL_OS_WINDOWS } diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index 952616aa9..bde3f2c96 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -79,16 +79,44 @@ struct BNPHeader if (f == NULL) return false; uint32 nNbFile = (uint32)Files.size(); - fwrite (&nNbFile, sizeof(uint32), 1, f); + if (fwrite (&nNbFile, sizeof(uint32), 1, f) != 1) + { + fclose(f); + return false; + } for (uint32 i = 0; i < nNbFile; ++i) { uint8 nStringSize = (uint8)Files[i].Name.size(); - fwrite (&nStringSize, 1, 1, f); - fwrite (Files[i].Name.c_str(), 1, nStringSize, f); - fwrite (&Files[i].Size, sizeof(uint32), 1, f); - fwrite (&Files[i].Pos, sizeof(uint32), 1, f); + if (fwrite (&nStringSize, 1, 1, f) != 1) + { + fclose(f); + return false; + } + + if (fwrite (Files[i].Name.c_str(), 1, nStringSize, f) != nStringSize) + { + fclose(f); + return false; + } + + if (fwrite (&Files[i].Size, sizeof(uint32), 1, f) != 1) + { + fclose(f); + return false; + } + + if (fwrite (&Files[i].Pos, sizeof(uint32), 1, f) != 1) + { + fclose(f); + return false; + } + } + + if (fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f) != 1) + { + fclose(f); + return false; } - fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f); fclose (f); return true; @@ -103,29 +131,54 @@ struct BNPHeader nlfseek64 (f, 0, SEEK_END); uint32 nFileSize=CFile::getFileSize (filename); nlfseek64 (f, nFileSize-sizeof(uint32), SEEK_SET); + uint32 nOffsetFromBegining; - fread (&nOffsetFromBegining, sizeof(uint32), 1, f); - if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) + if (fread (&nOffsetFromBegining, sizeof(uint32), 1, f) != 1) + { + fclose (f); return false; + } + + if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) + { + fclose (f); + return false; + } uint32 nNbFile; if (fread (&nNbFile, sizeof(uint32), 1, f) != 1) + { + fclose (f); return false; + } + for (uint32 i = 0; i < nNbFile; ++i) { uint8 nStringSize; char sName[256]; if (fread (&nStringSize, 1, 1, f) != 1) + { + fclose (f); return false; + } if (fread (sName, 1, nStringSize, f) != nStringSize) + { + fclose (f); return false; + } sName[nStringSize] = 0; BNPFile tmpBNPFile; tmpBNPFile.Name = sName; if (fread (&tmpBNPFile.Size, sizeof(uint32), 1, f) != 1) + { + fclose (f); return false; + } if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1) + { + fclose (f); return false; + } Files.push_back (tmpBNPFile); } @@ -146,9 +199,11 @@ void append(const string &filename1, const string &filename2, uint32 sizeToRead) if (f2 == NULL) { fclose(f1); return; } uint8 *ptr = new uint8[sizeToRead]; - fread (ptr, sizeToRead, 1, f2); - fwrite (ptr, sizeToRead, 1, f1); - delete ptr; + if (fread (ptr, sizeToRead, 1, f2) != 1) + nlwarning("%s read error", filename2.c_str()); + if (fwrite (ptr, sizeToRead, 1, f1) != 1) + nlwarning("%s write error", filename1.c_str()); + delete [] ptr; fclose(f2); fclose(f1); @@ -216,10 +271,12 @@ void unpack (const string &dirName) { nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET); uint8 *ptr = new uint8[rBNPFile.Size]; - fread (ptr, rBNPFile.Size, 1, bnp); - fwrite (ptr, rBNPFile.Size, 1, out); + if (fread (ptr, rBNPFile.Size, 1, bnp) != 1) + nlwarning("%s read error", filename.c_str()); + if (fwrite (ptr, rBNPFile.Size, 1, out) != 1) + nlwarning("%s write error", filename.c_str()); fclose (out); - delete ptr; + delete [] ptr; } } fclose (bnp); diff --git a/code/nel/tools/misc/xml_packer/xml_packer.cpp b/code/nel/tools/misc/xml_packer/xml_packer.cpp index 3e96f4615..c05b7590d 100644 --- a/code/nel/tools/misc/xml_packer/xml_packer.cpp +++ b/code/nel/tools/misc/xml_packer/xml_packer.cpp @@ -297,7 +297,11 @@ int main(int argc, char *argv[]) } fclose(fp); // set the file 'hidden'n use the plain old system command... - system(toString("attrib +h %s", indexFileName.c_str()).c_str()); + sint res = system(toString("attrib +h %s", indexFileName.c_str()).c_str()); + if (res) + { + nlwarning("attrib failed with return code %d", res); + } } else {