Fix compiler warnings (mainly signed/unsigned comparisons)

This commit is contained in:
Peter Wu 2012-08-25 19:21:58 +02:00
parent 9b3037d0e4
commit 689eb74945
4 changed files with 8 additions and 6 deletions

View file

@ -61,10 +61,10 @@ void Util::Config::addOption(std::string optname, JSON::Value option){
/// Prints a usage message to the given output. /// Prints a usage message to the given output.
void Util::Config::printHelp(std::ostream & output){ void Util::Config::printHelp(std::ostream & output){
int longest = 0; unsigned int longest = 0;
std::map<long long int, std::string> args; std::map<long long int, std::string> args;
for (JSON::ObjIter it = vals.ObjBegin(); it != vals.ObjEnd(); it++){ for (JSON::ObjIter it = vals.ObjBegin(); it != vals.ObjEnd(); it++){
int current = 0; unsigned int current = 0;
if (it->second.isMember("long")){current += it->second["long"].asString().size() + 4;} if (it->second.isMember("long")){current += it->second["long"].asString().size() + 4;}
if (it->second.isMember("short")){current += it->second["short"].asString().size() + 3;} if (it->second.isMember("short")){current += it->second["short"].asString().size() + 3;}
if (current > longest){longest = current;} if (current > longest){longest = current;}

View file

@ -217,7 +217,8 @@ DTSC::File::File(std::string filename, bool create){
fwrite(buffer, 4, 1, F);//write 4 zero-bytes fwrite(buffer, 4, 1, F);//write 4 zero-bytes
headerSize = 0; headerSize = 0;
}else{ }else{
headerSize = ntohl(((uint32_t *)buffer)[0]); uint32_t * ubuffer = (uint32_t *)buffer;
headerSize = ntohl(ubuffer[0]);
} }
fseek(F, 8+headerSize, SEEK_SET); fseek(F, 8+headerSize, SEEK_SET);
} }
@ -264,7 +265,8 @@ std::string & DTSC::File::getPacket(){
strbuffer = ""; strbuffer = "";
return strbuffer; return strbuffer;
} }
long packSize = ntohl(((uint32_t *)buffer)[0]); uint32_t * ubuffer = (uint32_t *)buffer;
long packSize = ntohl(ubuffer[0]);
strbuffer.resize(packSize); strbuffer.resize(packSize);
if (fread((void*)strbuffer.c_str(), packSize, 1, F) != 1){ if (fread((void*)strbuffer.c_str(), packSize, 1, F) != 1){
fprintf(stderr, "Could not read packet\n"); fprintf(stderr, "Could not read packet\n");

View file

@ -73,7 +73,7 @@ namespace DTSC{
private: private:
std::string strbuffer; std::string strbuffer;
FILE * F; FILE * F;
long headerSize; unsigned long headerSize;
char buffer[4]; char buffer[4];
};//FileWriter };//FileWriter

View file

@ -480,7 +480,7 @@ std::string JSON::Value::toPrettyString(int indentation){
break; break;
} }
case STRING: { case STRING: {
for (int i = 0; i < 5 && i < strVal.size(); ++i){ for (unsigned int i = 0; i < 5 && i < strVal.size(); ++i){
if (strVal[i] < 32 || strVal[i] > 125){ if (strVal[i] < 32 || strVal[i] > 125){
return JSON::Value((long long int)strVal.size()).asString()+" bytes of binary data"; return JSON::Value((long long int)strVal.size()).asString()+" bytes of binary data";
} }