Fix a big heap of warnings.

develop
Petr Mrázek 2011-05-15 22:24:40 +02:00
parent 515f4952a9
commit 61dea59e29
11 changed files with 92 additions and 101 deletions

@ -106,7 +106,7 @@ bool LinuxProcessBase::getThreadIDs(vector<uint32_t> & threads )
return false; return false;
} }
threads.clear(); threads.clear();
for(int i = 0; i < subdirs.size();i++) for(size_t i = 0; i < subdirs.size();i++)
{ {
uint32_t tid; uint32_t tid;
if(sscanf(subdirs[i].c_str(),"%d", &tid)) if(sscanf(subdirs[i].c_str(),"%d", &tid))

@ -223,97 +223,82 @@ const char* Process_readClassName(DFHackObject* p_Ptr, uint32_t vptr)
uint32_t* Process_getThreadIDs(DFHackObject* p_Ptr) uint32_t* Process_getThreadIDs(DFHackObject* p_Ptr)
{ {
if(p_Ptr == NULL || alloc_uint_buffer_callback == NULL) if(p_Ptr == NULL || alloc_uint_buffer_callback == NULL)
return NULL; return NULL;
std::vector<uint32_t> threads; std::vector<uint32_t> threads;
if(((DFHack::Process*)p_Ptr)->getThreadIDs(threads)) if(((DFHack::Process*)p_Ptr)->getThreadIDs(threads))
{ {
uint32_t* buf; uint32_t* buf;
if(threads.size() > 0)
if(threads.size() > 0) {
{ ((*alloc_uint_buffer_callback)(&buf, threads.size()));
((*alloc_uint_buffer_callback)(&buf, threads.size())); if(buf == NULL)
return NULL;
if(buf == NULL) copy(threads.begin(), threads.end(), buf);
return NULL; return buf;
}
copy(threads.begin(), threads.end(), buf); }
return NULL;
return buf;
}
}
else
return NULL;
} }
t_memrange* Process_getMemRanges(DFHackObject* p_Ptr) t_memrange* Process_getMemRanges(DFHackObject* p_Ptr)
{ {
if(p_Ptr == NULL || alloc_memrange_buffer_callback == NULL) if(p_Ptr == NULL || alloc_memrange_buffer_callback == NULL)
return NULL; return NULL;
std::vector<t_memrange> ranges; std::vector<t_memrange> ranges;
((DFHack::Process*)p_Ptr)->getMemRanges(ranges); ((DFHack::Process*)p_Ptr)->getMemRanges(ranges);
if(ranges.size() > 0) if(ranges.size() > 0)
{ {
t_memrange* buf; t_memrange* buf;
uint32_t* rangeDescriptorBuf = (uint32_t*)calloc(ranges.size(), sizeof(uint32_t)); uint32_t* rangeDescriptorBuf = (uint32_t*)calloc(ranges.size(), sizeof(uint32_t));
for(uint32_t i = 0; i < ranges.size(); i++) for(uint32_t i = 0; i < ranges.size(); i++)
{ {
t_memrange* r = &ranges[i]; t_memrange* r = &ranges[i];
rangeDescriptorBuf[i] = (uint32_t)(r->end - r->start);
rangeDescriptorBuf[i] = (uint32_t)(r->end - r->start); }
}
((*alloc_memrange_buffer_callback)(&buf, rangeDescriptorBuf, ranges.size()));
((*alloc_memrange_buffer_callback)(&buf, rangeDescriptorBuf, ranges.size())); free(rangeDescriptorBuf);
if(buf == NULL)
free(rangeDescriptorBuf); return NULL;
if(buf == NULL) for(uint32_t i = 0; i < ranges.size(); i++)
return NULL; {
t_memrange* r = &ranges[i];
for(uint32_t i = 0; i < ranges.size(); i++) buf[i].start = r->start;
{ buf[i].end = r->end;
t_memrange* r = &ranges[i]; memset(buf[i].name, '\0', 1024);
strncpy(buf[i].name, r->name, 1024);
buf[i].start = r->start; buf[i].read = r->read;
buf[i].end = r->end; buf[i].write = r->write;
buf[i].execute = r->execute;
memset(buf[i].name, '\0', 1024); buf[i].shared = r->shared;
strncpy(buf[i].name, r->name, 1024); buf[i].valid = r->valid;
memcpy(buf[i].buffer, r->buffer, r->end - r->start);
buf[i].read = r->read; }
buf[i].write = r->write; return buf;
buf[i].execute = r->execute; }
buf[i].shared = r->shared; return NULL;
buf[i].valid = r->valid;
memcpy(buf[i].buffer, r->buffer, r->end - r->start);
}
return buf;
}
else
return NULL;
} }
int Process_getPID(DFHackObject* p_Ptr, int32_t* pid) int Process_getPID(DFHackObject* p_Ptr, int32_t* pid)
{ {
if(p_Ptr == NULL) if(p_Ptr == NULL)
{ {
*pid = -1; *pid = -1;
return -1; return -1;
} }
else else
{ {
*pid = ((DFHack::Process*)p_Ptr)->getPID(); *pid = ((DFHack::Process*)p_Ptr)->getPID();
return 1;
return 1; }
}
} }
int Process_getModuleIndex(DFHackObject* p_Ptr, char* name, uint32_t version, uint32_t* output) int Process_getModuleIndex(DFHackObject* p_Ptr, char* name, uint32_t version, uint32_t* output)

@ -658,7 +658,7 @@ namespace DFHack
int32_t findSimilarTileType( const int32_t sourceTileType, const TileShape tshape ) int32_t findSimilarTileType( const int32_t sourceTileType, const TileShape tshape )
{ {
int32_t tt, maybe=0, match=0; int32_t tt, match=0;
int value=0, matchv=0; int value=0, matchv=0;
const TileRow *source = &tileTypeTable[sourceTileType]; const TileRow *source = &tileTypeTable[sourceTileType];
@ -676,7 +676,7 @@ namespace DFHack
//Special flag match is absolutely mandatory! //Special flag match is absolutely mandatory!
if( source->special != tileTypeTable[tt].special ) continue; if( source->special != tileTypeTable[tt].special ) continue;
maybe=tt; value=0; value=0;
//Material is high-value match //Material is high-value match
if( tileTypeTable[tt].material == source->material ) value|=8; if( tileTypeTable[tt].material == source->material ) value|=8;
//Direction is medium value match //Direction is medium value match
@ -685,7 +685,8 @@ namespace DFHack
if( tileTypeTable[tt].variant == source->variant ) value|=1; if( tileTypeTable[tt].variant == source->variant ) value|=1;
//Check value against last match //Check value against last match
if( value>matchv ){ if( value>matchv )
{
match=tt; match=tt;
matchv=value; matchv=value;
} }

@ -229,7 +229,7 @@ void OffsetGroup::setAddress (const string & key, const string & value, const IN
uint32_Iter it = OGd->addresses.find(key); uint32_Iter it = OGd->addresses.find(key);
if(it != OGd->addresses.end()) if(it != OGd->addresses.end())
{ {
int32_t address = strtol(value.c_str(), NULL, 16); uint32_t address = strtol(value.c_str(), NULL, 16);
if((*it).second.second == address) if((*it).second.second == address)
std::cout << "Pointless address setting: " << this->getFullName() + key << endl; std::cout << "Pointless address setting: " << this->getFullName() + key << endl;
(*it).second.second = address; (*it).second.second = address;
@ -484,7 +484,7 @@ std::string OffsetGroup::PrintOffsets(int indentation)
} }
} }
std::sort(addrsorter.begin(), addrsorter.end(), compare_pair_first<>()); std::sort(addrsorter.begin(), addrsorter.end(), compare_pair_first<>());
for(int idx = 0; idx < addrsorter.size();idx++) for(size_t idx = 0; idx < addrsorter.size();idx++)
{ {
horrible & h = addrsorter[idx]; horrible & h = addrsorter[idx];
ss << i << "<Address name=\"" << h.second.first << "\""; ss << i << "<Address name=\"" << h.second.first << "\"";
@ -511,7 +511,7 @@ std::string OffsetGroup::PrintOffsets(int indentation)
} }
} }
std::sort(offsorter.begin(), offsorter.end(), compare_pair_first<>()); std::sort(offsorter.begin(), offsorter.end(), compare_pair_first<>());
for(int idx = 0; idx < offsorter.size();idx++) for(size_t idx = 0; idx < offsorter.size();idx++)
{ {
terrible & h = offsorter[idx]; terrible & h = offsorter[idx];
ss << i << "<Offset name=\"" << h.second.first << "\""; ss << i << "<Offset name=\"" << h.second.first << "\"";

@ -187,7 +187,7 @@ namespace DFHack
virtual std::string doReadClassName(uint32_t vptr) = 0; virtual std::string doReadClassName(uint32_t vptr) = 0;
std::string readClassName(uint32_t vptr) std::string readClassName(uint32_t vptr)
{ {
std::map<uint32_t, std::string>::iterator it = classNameCache.find(vptr); std::map<uint32_t, std::string>::iterator it = classNameCache.find(vptr);
if (it != classNameCache.end()) if (it != classNameCache.end())
return it->second; return it->second;

@ -43,6 +43,7 @@ namespace DFHack
Process *_p; Process *_p;
uint32_t _address; uint32_t _address;
t_vecTriplet t; t_vecTriplet t;
t_vecTriplet t_read;
uint32_t _size;// vector size uint32_t _size;// vector size
T * data; // cached data T * data; // cached data
@ -57,6 +58,7 @@ namespace DFHack
DfVector(Process *p, uint32_t address) : _p(p), _address(address) DfVector(Process *p, uint32_t address) : _p(p), _address(address)
{ {
p->readSTLVector(address,t); p->readSTLVector(address,t);
t_read = t;
uint32_t byte_size = t.end - t.start; uint32_t byte_size = t.end - t.start;
_size = byte_size / sizeof(T); _size = byte_size / sizeof(T);
data = new T[_size]; data = new T[_size];

@ -148,6 +148,7 @@ uint32_t Gui::ReadMenuState()
return false; return false;
} }
// FIXME: variable screenAddr set but not used [-Wunused-but-set-variable]
bool Gui::ReadViewScreen (t_viewscreen &screen) bool Gui::ReadViewScreen (t_viewscreen &screen)
{ {
if (!d->ViewScreeInited) return false; if (!d->ViewScreeInited) return false;

@ -353,7 +353,6 @@ Accessor * buildAccessor (OffsetGroup * I, Process * p, const char * name, uint3
ItemDesc::ItemDesc(uint32_t VTable, Process *p) ItemDesc::ItemDesc(uint32_t VTable, Process *p)
{ {
int32_t funcOffsetA, funcOffsetB, funcOffsetC, funcOffsetD, funcOffsetQuality, funcOffsetWear;
OffsetGroup * Items = p->getDescriptor()->getGroup("Items"); OffsetGroup * Items = p->getDescriptor()->getGroup("Items");
/* /*
@ -381,7 +380,7 @@ ItemDesc::ItemDesc(uint32_t VTable, Process *p)
mainType = this->AMainType->getValue(0); mainType = this->AMainType->getValue(0);
else else
{ {
fprintf(stderr, "Bad item main type at function %p\n", (void*) p->readDWord( VTable + funcOffsetA )); cerr << "Bad item main type accessor: " << AMainType->dump() << endl;
mainType = 0; mainType = 0;
} }
} }

@ -802,7 +802,7 @@ bool Maps::StartFeatures()
t_feature * Maps::GetGlobalFeature(int16_t index) t_feature * Maps::GetGlobalFeature(int16_t index)
{ {
if(!d->FeaturesStarted) return 0; if(!d->FeaturesStarted) return 0;
if(index < 0 || index >= d->v_global_feature.size()) if(index < 0 || uint16_t(index) >= d->v_global_feature.size())
return 0; return 0;
return &(d->v_global_feature[index]); return &(d->v_global_feature[index]);
} }

@ -356,9 +356,10 @@ bool Materials::ReadCreatureTypesEx (void)
uint32_t caste_bodypart_offset; uint32_t caste_bodypart_offset;
uint32_t bodypart_id_offset; uint32_t bodypart_id_offset;
uint32_t bodypart_category_offset; uint32_t bodypart_category_offset;
uint32_t bodypart_layers_offset; //FIXME: this is unused. why do we mess with it when it's not even read?
uint32_t bodypart_singular_offset; //uint32_t bodypart_layers_offset;
uint32_t bodypart_plural_offset; //uint32_t bodypart_singular_offset;
//uint32_t bodypart_plural_offset;
uint32_t color_modifier_part_offset; uint32_t color_modifier_part_offset;
uint32_t color_modifier_startdate_offset; uint32_t color_modifier_startdate_offset;
uint32_t color_modifier_enddate_offset; uint32_t color_modifier_enddate_offset;
@ -371,9 +372,9 @@ bool Materials::ReadCreatureTypesEx (void)
OffsetGroup * OG_CasteBodyparts = OG_Creature->getGroup("caste_bodyparts"); OffsetGroup * OG_CasteBodyparts = OG_Creature->getGroup("caste_bodyparts");
bodypart_id_offset = OG_CasteBodyparts->getOffset ("id"); bodypart_id_offset = OG_CasteBodyparts->getOffset ("id");
bodypart_category_offset = OG_CasteBodyparts->getOffset ("category"); bodypart_category_offset = OG_CasteBodyparts->getOffset ("category");
bodypart_layers_offset = OG_CasteBodyparts->getOffset ("layers_vector"); // unused //bodypart_layers_offset = OG_CasteBodyparts->getOffset ("layers_vector"); // unused
bodypart_singular_offset = OG_CasteBodyparts->getOffset ("singular_vector"); // unused //bodypart_singular_offset = OG_CasteBodyparts->getOffset ("singular_vector"); // unused
bodypart_plural_offset = OG_CasteBodyparts->getOffset ("plural_vector"); // unused //bodypart_plural_offset = OG_CasteBodyparts->getOffset ("plural_vector"); // unused
OffsetGroup * OG_CasteColorMods = OG_Creature->getGroup("caste_color_mods"); OffsetGroup * OG_CasteColorMods = OG_Creature->getGroup("caste_color_mods");
color_modifier_part_offset = OG_CasteColorMods->getOffset ("part"); color_modifier_part_offset = OG_CasteColorMods->getOffset ("part");
color_modifier_startdate_offset = OG_CasteColorMods->getOffset ("startdate"); color_modifier_startdate_offset = OG_CasteColorMods->getOffset ("startdate");
@ -480,11 +481,11 @@ void Materials::ReadAllMaterials(void)
} }
/// miserable pile of magic. The material system is insane. /// miserable pile of magic. The material system is insane.
// FIXME: this contains potential errors when the indexes are -1 and compared to unsigned numbers!
std::string Materials::getDescription(const t_material & mat) std::string Materials::getDescription(const t_material & mat)
{ {
std::string out; std::string out;
int32_t typeC; int32_t typeC;
if ( (mat.subIndex<419) || (mat.subIndex>618) ) if ( (mat.subIndex<419) || (mat.subIndex>618) )
{ {
if ( (mat.subIndex<19) || (mat.subIndex>218) ) if ( (mat.subIndex<19) || (mat.subIndex>218) )
@ -543,6 +544,7 @@ std::string Materials::getDescription(const t_material & mat)
} }
//type of material only so we know which vector to retrieve //type of material only so we know which vector to retrieve
// FIXME: this also contains potential errors when the indexes are -1 and compared to unsigned numbers!
std::string Materials::getType(const t_material & mat) std::string Materials::getType(const t_material & mat)
{ {
if((mat.subIndex<419) || (mat.subIndex>618)) if((mat.subIndex<419) || (mat.subIndex>618))

@ -13,6 +13,7 @@ using namespace std;
using namespace DFHack; using namespace DFHack;
//FIXME: A pile of magic numbers. looks like decompiled number
typedef uint32_t _DWORD; typedef uint32_t _DWORD;
int get_material_vector(uint32_t vein_8, uint16_t vein_4, int WORLD_) int get_material_vector(uint32_t vein_8, uint16_t vein_4, int WORLD_)
{ {