From 3888d0fc06971ccc0448b1a8eb00fcc02a0e58d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 13 Dec 2009 21:03:19 +0000 Subject: [PATCH] fixed tons of warnings, removed dependency on xtest --- library/CMakeLists.txt | 5 +++-- library/DFDataModel.cpp | 12 ++++++------ library/DFHackAPI.cpp | 14 +++++++------- library/DFKeys-linux.cpp | 10 +++------- library/DFKeys.h | 2 +- library/DFMemInfoManager.cpp | 6 +++--- library/DFMemInfoManager.h | 2 +- library/DFProcess-linux.cpp | 11 ++++------- library/DFProcess.h | 2 +- library/DFProcessEnumerator-linux.cpp | 4 ++-- library/DFTypes.h | 2 +- library/MemAccess-linux.h | 3 ++- library/tinyxml/tinyxmlparser.cpp | 2 +- tools/attachtest.cpp | 2 +- tools/buildingsdump.cpp | 2 +- tools/cleanmap.cpp | 2 +- tools/creaturedump.cpp | 2 +- tools/dfitemdump.cpp | 6 +++--- tools/expbench.cpp | 2 +- tools/incrementalsearch.cpp | 2 +- tools/materialtest.cpp | 2 +- tools/position.cpp | 2 +- tools/prospector.cpp | 4 ++-- tools/reveal.cpp | 4 +--- 24 files changed, 49 insertions(+), 56 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index feb157266..7b01f22fd 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -82,8 +82,9 @@ IF(UNIX) add_definitions(-DLINUX_BUILD) add_definitions(-DUSE_CONFIG_H) find_library(X11_LIBRARY X11) - find_library(XTEST_LIBRARY Xtst) - SET(PROJECT_LIBS ${X11_LIBRARY} ${XTEST_LIBRARY}) + SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -pedantic") + + SET(PROJECT_LIBS ${X11_LIBRARY}) ELSE(UNIX) SET(PROJECT_LIBS psapi) ENDIF(UNIX) diff --git a/library/DFDataModel.cpp b/library/DFDataModel.cpp index 364e9d9a4..4be7c50e0 100644 --- a/library/DFDataModel.cpp +++ b/library/DFDataModel.cpp @@ -41,7 +41,7 @@ DfVector DMWindows40d::readVector (uint32_t offset, uint32_t item_size) uint32_t end = MreadDWord(offset+8); uint32_t size = (end - start) /4; return DfVector(start,size,item_size); -}; +} size_t DMWindows40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) @@ -76,7 +76,7 @@ Uint32 capacity buffer[read_real] = 0; return read_real; -}; +} const string DMWindows40d::readSTLString (uint32_t offset) { @@ -111,7 +111,7 @@ const string DMWindows40d::readSTLString (uint32_t offset) string ret = temp; delete temp; return ret; -}; +} DfVector DMLinux40d::readVector (uint32_t offset, uint32_t item_size) @@ -128,7 +128,7 @@ DfVector DMLinux40d::readVector (uint32_t offset, uint32_t item_size) uint32_t end = MreadDWord(offset+4); uint32_t size = (end - start) /4; return DfVector(start,size,item_size); -}; +} struct _Rep_base { @@ -146,7 +146,7 @@ size_t DMLinux40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapa Mread(offset,read_real,(uint8_t * )buffer); buffer[read_real] = 0; return read_real; -}; +} const string DMLinux40d::readSTLString (uint32_t offset) { @@ -161,4 +161,4 @@ const string DMLinux40d::readSTLString (uint32_t offset) string ret(temp); delete temp; return ret; -}; +} diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp index 244262fae..bd2675d03 100644 --- a/library/DFHackAPI.cpp +++ b/library/DFHackAPI.cpp @@ -283,7 +283,7 @@ bool API::getCurrentCursorCreatures (vector &addresses) return false; } addresses.clear(); - for (int i = 0;i < creUnderCursor.getSize();i++) + for (uint32_t i = 0;i < creUnderCursor.getSize();i++) { uint32_t temp = * (uint32_t *) creUnderCursor.at (i); addresses.push_back (temp); @@ -406,7 +406,7 @@ bool API::ReadStoneMatgloss (vector & stones) int matgloss_colors = minfo->getOffset ("matgloss_stone_color"); DfVector p_matgloss = d->dm->readVector (matgloss_address + matgloss_offset, 4); - int size = p_matgloss.getSize(); + uint32_t size = p_matgloss.getSize(); stones.resize (0); stones.reserve (size); for (uint32_t i = 0; i < size;i++) @@ -992,7 +992,7 @@ int32_t API::ReadCreatureInBox (int32_t index, t_creature & furball, uint16_t coords[3]; assert (d->creaturesInited); uint32_t size = d->p_cre->getSize(); - while (index < size) + while (uint32_t(index) < size) { // read pointer from vector at position uint32_t temp = * (uint32_t *) d->p_cre->at (index); @@ -1056,7 +1056,8 @@ bool API::ReadCreature (const int32_t &index, t_creature & furball) furball.profession = MreadByte (temp + d->creature_profession_offset); // current job HACK: the job object isn't cleanly represented here uint32_t jobIdAddr = MreadDWord (temp + d->creature_current_job_offset); - if (furball.current_job.active = jobIdAddr != 0) + furball.current_job.active = jobIdAddr; + if (jobIdAddr) { furball.current_job.jobId = MreadByte (jobIdAddr + d->creature_current_job_id_offset); } @@ -1081,9 +1082,8 @@ void API::InitReadNameTables (map< string, vector > & nameTable) DfVector genericVec (d->dm->readVector (genericAddress, 4)); DfVector transVec (d->dm->readVector (transAddress, 4)); - uint32_t dwarf_entry = 0; - for (int32_t i = 0;i < genericVec.getSize();i++) + for (uint32_t i = 0;i < genericVec.getSize();i++) { uint32_t genericNamePtr = * (uint32_t *) genericVec.at (i); string genericName = d->dm->readSTLString (genericNamePtr); @@ -1134,7 +1134,7 @@ string API::TranslateName (const t_squadname & squad, const map //need for X11 functions -#include //need for Xtest -#include //for the atom stuff #define XK_MISCELLANY #define XK_LATIN1 #include @@ -115,7 +113,7 @@ Window EnumerateWindows (Display *display, Window rootWindow, const char *search } // recurse into children - for (int i = 0; i < noOfChildren; i++) + for (uint32_t i = 0; i < noOfChildren; i++) { Window tempWindow = EnumerateWindows (display, children[i], searchString); if (tempWindow != BadWindow) @@ -183,14 +181,12 @@ void API::TypeStr (const char *lpszString, int delay, bool useShift) char cChar; int realDelay = delay * 1000; KeyCode xkeycode; - char prevKey = 0; - int sleepAmnt = 0; while ( (cChar = *lpszString++)) // loops through chars { // HACK: the timing here is a strange beast xkeycode = XKeysymToKeycode (dpy, cChar); send_xkeyevent(dpy,dfWin,rootWin,XKeysymToKeycode(dpy, ksTable[DFHack::LEFT_SHIFT]),0,false, realDelay); - if (useShift || cChar >= 'A' && cChar <= 'Z') + if (useShift || (cChar >= 'A' && cChar <= 'Z')) { send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,true, realDelay); send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,false, realDelay); @@ -243,4 +239,4 @@ void API::TypeSpecial (t_special command, int count, int delay) { usleep (delay*1000 * count); } -} \ No newline at end of file +} diff --git a/library/DFKeys.h b/library/DFKeys.h index 3e48baa90..05527a92a 100644 --- a/library/DFKeys.h +++ b/library/DFKeys.h @@ -83,4 +83,4 @@ enum t_special NUM_SPECIALS }; } -#endif // KEYS_H_INCLUDED \ No newline at end of file +#endif // KEYS_H_INCLUDED diff --git a/library/DFMemInfoManager.cpp b/library/DFMemInfoManager.cpp index a487e519b..098372015 100644 --- a/library/DFMemInfoManager.cpp +++ b/library/DFMemInfoManager.cpp @@ -241,8 +241,8 @@ bool MemInfoManager::loadFile(string path_to_xml) for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Entry")) { v_pEntries.push_back(pMemInfo); - const char *id; - if(id= pMemInfo->Attribute("id")) + const char *id = pMemInfo->Attribute("id"); + if(id) { string str_id = id; map_pNamedEntries[str_id] = pMemInfo; @@ -267,4 +267,4 @@ bool MemInfoManager::loadFile(string path_to_xml) error = true; return false; } -} \ No newline at end of file +} diff --git a/library/DFMemInfoManager.h b/library/DFMemInfoManager.h index 535757dac..4fcc6f682 100644 --- a/library/DFMemInfoManager.h +++ b/library/DFMemInfoManager.h @@ -43,4 +43,4 @@ namespace DFHack }; } -#endif \ No newline at end of file +#endif diff --git a/library/DFProcess-linux.cpp b/library/DFProcess-linux.cpp index 19fa0c0eb..615010298 100644 --- a/library/DFProcess-linux.cpp +++ b/library/DFProcess-linux.cpp @@ -135,9 +135,6 @@ bool Process::Private::validate(char * exe_file,uint32_t pid, char * memFile, ve if(hash == (*it).getString("md5")) // are the md5 hashes the same? { memory_info * m = &*it; - Process * ret; - //cout <<"Found process " << PH << ". It's DF version " << m->getVersion() << "." << endl; - // df can run under wine on Linux if(memory_info::OS_WINDOWS == (*it).getOS()) { @@ -197,12 +194,11 @@ bool Process::getThreadIDs(vector & threads ) void Process::getMemRanges( vector & ranges ) { char buffer[1024]; - char name[1024]; char permissions[5]; // r/-, w/-, x/-, p/s, 0 sprintf(buffer, "/proc/%lu/maps", d->my_pid); FILE *mapFile = ::fopen(buffer, "r"); - uint64_t begin, end, offset, device1, device2, node; + uint64_t offset, device1, device2, node; while (fgets(buffer, 1024, mapFile)) { @@ -251,6 +247,7 @@ bool Process::suspend() } } d->suspended = true; + return true; } bool Process::forceresume() @@ -260,7 +257,6 @@ bool Process::forceresume() bool Process::resume() { - int status; if(!d->attached) return false; if(!d->suspended) @@ -272,6 +268,7 @@ bool Process::resume() return false; } d->suspended = false; + return true; } @@ -359,4 +356,4 @@ bool Process::detach() return true; } } -} \ No newline at end of file +} diff --git a/library/DFProcess.h b/library/DFProcess.h index f50caf1d4..6be9d48ff 100644 --- a/library/DFProcess.h +++ b/library/DFProcess.h @@ -85,4 +85,4 @@ namespace DFHack DataModel *getDataModel(); }; } -#endif \ No newline at end of file +#endif diff --git a/library/DFProcessEnumerator-linux.cpp b/library/DFProcessEnumerator-linux.cpp index e386a1a6e..145c88ac7 100644 --- a/library/DFProcessEnumerator-linux.cpp +++ b/library/DFProcessEnumerator-linux.cpp @@ -87,14 +87,14 @@ bool ProcessEnumerator::findProcessess() uint32_t ProcessEnumerator::size() { return d->processes.size(); -}; +} Process * ProcessEnumerator::operator[](uint32_t index) { assert(index < d->processes.size()); return d->processes[index]; -}; +} ProcessEnumerator::ProcessEnumerator( string path_to_xml ) diff --git a/library/DFTypes.h b/library/DFTypes.h index 08f218246..fd5ea064e 100644 --- a/library/DFTypes.h +++ b/library/DFTypes.h @@ -192,7 +192,7 @@ enum MatglossType Mat_Potash = 20, Mat_Ashes = 20, Mat_PearlAsh = 21, - Mat_Soap = 24, + Mat_Soap = 24 //NUM_MATGLOSS_TYPES }; diff --git a/library/MemAccess-linux.h b/library/MemAccess-linux.h index b520c0ba4..128bb1356 100644 --- a/library/MemAccess-linux.h +++ b/library/MemAccess-linux.h @@ -37,7 +37,7 @@ void Mread (const uint32_t &offset, const uint32_t &size, uint8_t *target) { if(size == 0) return; - int result; + ssize_t result; result = pread(DFHack::g_ProcessMemFile, target,size,offset); if(result != size) { @@ -162,6 +162,7 @@ bool Mwrite (uint32_t offset, uint32_t size, uint8_t *source) return true; } } + return false; // dead code } inline diff --git a/library/tinyxml/tinyxmlparser.cpp b/library/tinyxml/tinyxmlparser.cpp index 9c91b4f94..5793f0528 100644 --- a/library/tinyxml/tinyxmlparser.cpp +++ b/library/tinyxml/tinyxmlparser.cpp @@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) } else { - while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) + while ( (*p && IsWhiteSpace( *p )) || *p == '\n' || *p =='\r' ) ++p; } diff --git a/tools/attachtest.cpp b/tools/attachtest.cpp index 687d8593e..a17966475 100644 --- a/tools/attachtest.cpp +++ b/tools/attachtest.cpp @@ -82,4 +82,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/buildingsdump.cpp b/tools/buildingsdump.cpp index cadc4cc27..836b66595 100644 --- a/tools/buildingsdump.cpp +++ b/tools/buildingsdump.cpp @@ -158,4 +158,4 @@ int main (int argc,const char* argv[]) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/cleanmap.cpp b/tools/cleanmap.cpp index 5c7da687a..3b0f6108a 100644 --- a/tools/cleanmap.cpp +++ b/tools/cleanmap.cpp @@ -52,4 +52,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/creaturedump.cpp b/tools/creaturedump.cpp index 739e81dbf..b72a6f721 100644 --- a/tools/creaturedump.cpp +++ b/tools/creaturedump.cpp @@ -182,4 +182,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/dfitemdump.cpp b/tools/dfitemdump.cpp index 54f9bc539..f26135947 100644 --- a/tools/dfitemdump.cpp +++ b/tools/dfitemdump.cpp @@ -78,7 +78,6 @@ int main () DF.ReadCreatureMatgloss(mat.creatureMat); vector buildingtypes; - uint32_t numBuildings = DF.InitReadBuildings(buildingtypes); DF.InitViewAndCursor(); cout << "q to quit, anything else to look up items at that location\n"; while(1) @@ -140,10 +139,11 @@ int main () } else{ cerr << "Please Select which item you want to display\n"; - for(int j = 0; j < foundItems.size(); ++j){ + for(uint32_t j = 0; j < foundItems.size(); ++j) + { cerr << j << " " << buildingtypes[foundItems[j].type] << endl; } - int value; + uint32_t value; string input2; stringstream ss; getline(cin, input2); diff --git a/tools/expbench.cpp b/tools/expbench.cpp index 1b816dda5..d3d3fe4c0 100644 --- a/tools/expbench.cpp +++ b/tools/expbench.cpp @@ -68,4 +68,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/incrementalsearch.cpp b/tools/incrementalsearch.cpp index 39f148a9c..4b48d6535 100644 --- a/tools/incrementalsearch.cpp +++ b/tools/incrementalsearch.cpp @@ -217,4 +217,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/materialtest.cpp b/tools/materialtest.cpp index 9379b48ac..7bbc9e03d 100644 --- a/tools/materialtest.cpp +++ b/tools/materialtest.cpp @@ -43,4 +43,4 @@ int main (void) #endif return 0; -} \ No newline at end of file +} diff --git a/tools/position.cpp b/tools/position.cpp index be5a3e967..5edc4f1a7 100644 --- a/tools/position.cpp +++ b/tools/position.cpp @@ -53,4 +53,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/prospector.cpp b/tools/prospector.cpp index d8f04b1ca..eb4250ca0 100644 --- a/tools/prospector.cpp +++ b/tools/prospector.cpp @@ -145,7 +145,7 @@ int main (int argc, const char* argv[]) { // hidden tiles are ignored unless '-a' is provided on the command line // non-wall tiles are ignored - if(designations[xi][yi].bits.hidden && !showhidden || !DFHack::isWallTerrain(tiletypes[xi][yi])) + if( (designations[xi][yi].bits.hidden && !showhidden) || !DFHack::isWallTerrain(tiletypes[xi][yi])) continue; if(tempvein[xi][yi] < 0) continue; @@ -175,4 +175,4 @@ int main (int argc, const char* argv[]) cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/reveal.cpp b/tools/reveal.cpp index ed38c75c3..a469adbe2 100644 --- a/tools/reveal.cpp +++ b/tools/reveal.cpp @@ -11,8 +11,6 @@ using namespace std; int main (void) { uint32_t x_max,y_max,z_max; - uint32_t num_blocks = 0; - uint32_t bytes_read = 0; DFHack::t_designation designations[256]; DFHack::API DF("Memory.xml"); @@ -52,4 +50,4 @@ int main (void) cin.ignore(); #endif return 0; -} \ No newline at end of file +}