From 6faf377b5305f9dcc3c7b013c4d67f5accb92617 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 4 Jun 2009 23:21:12 -0700 Subject: types: clean up types, especially signed vs unsigned --- src/sim/init.cc | 2 +- src/sim/process.cc | 4 ++-- src/sim/process_impl.hh | 2 +- src/sim/pseudo_inst.cc | 2 +- src/sim/serialize.cc | 20 +++++++++----------- src/sim/serialize.hh | 4 ++-- src/sim/syscall_emul.hh | 7 ++----- src/sim/system.hh | 2 +- 8 files changed, 19 insertions(+), 24 deletions(-) (limited to 'src/sim') diff --git a/src/sim/init.cc b/src/sim/init.cc index 1e90f1568..8057c9369 100644 --- a/src/sim/init.cc +++ b/src/sim/init.cc @@ -118,7 +118,7 @@ getCode(const EmbeddedPyModule *pymod) pymod->zlen); if (ret != Z_OK) panic("Could not uncompress code: %s\n", zError(ret)); - assert(unzlen == pymod->mlen); + assert(unzlen == (uLongf)pymod->mlen); return PyMarshal_ReadObjectFromString((char *)marshalled, pymod->mlen); } diff --git a/src/sim/process.cc b/src/sim/process.cc index c45844a51..c12101069 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -575,11 +575,11 @@ LiveProcess::argsInit(int intSize, int pageSize) int argv_array_size = intSize * (argv.size() + 1); int envp_array_size = intSize * (envp.size() + 1); int arg_data_size = 0; - for (int i = 0; i < argv.size(); ++i) { + for (vector::size_type i = 0; i < argv.size(); ++i) { arg_data_size += argv[i].size() + 1; } int env_data_size = 0; - for (int i = 0; i < envp.size(); ++i) { + for (vector::size_type i = 0; i < envp.size(); ++i) { env_data_size += envp[i].size() + 1; } diff --git a/src/sim/process_impl.hh b/src/sim/process_impl.hh index a3519fe39..9d12113d0 100644 --- a/src/sim/process_impl.hh +++ b/src/sim/process_impl.hh @@ -55,7 +55,7 @@ copyStringArray(std::vector &strings, TranslatingPort* memPort) { AddrType data_ptr_swap; - for (int i = 0; i < strings.size(); ++i) { + for (std::vector::size_type i = 0; i < strings.size(); ++i) { data_ptr_swap = htog(data_ptr); memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(AddrType)); diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index b5582578a..6182150d4 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -178,7 +178,7 @@ loadsymbol(ThreadContext *tc) if (buffer.empty()) continue; - int idx = buffer.find(' '); + string::size_type idx = buffer.find(' '); if (idx == string::npos) continue; diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index f73fc93a3..5ae9128e5 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -182,11 +182,11 @@ template void arrayParamOut(ostream &os, const string &name, const vector ¶m) { - int size = param.size(); + typename vector::size_type size = param.size(); os << name << "="; if (size > 0) showParam(os, param[0]); - for (int i = 1; i < size; ++i) { + for (typename vector::size_type i = 1; i < size; ++i) { os << " "; showParam(os, param[i]); } @@ -207,12 +207,12 @@ paramIn(Checkpoint *cp, const string §ion, const string &name, T ¶m) template void -arrayParamOut(ostream &os, const string &name, const T *param, int size) +arrayParamOut(ostream &os, const string &name, const T *param, unsigned size) { os << name << "="; if (size > 0) showParam(os, param[0]); - for (int i = 1; i < size; ++i) { + for (unsigned i = 1; i < size; ++i) { os << " "; showParam(os, param[i]); } @@ -223,7 +223,7 @@ arrayParamOut(ostream &os, const string &name, const T *param, int size) template void arrayParamIn(Checkpoint *cp, const string §ion, const string &name, - T *param, int size) + T *param, unsigned size) { string str; if (!cp->find(section, name, str)) { @@ -244,7 +244,7 @@ arrayParamIn(Checkpoint *cp, const string §ion, const string &name, fatal("Array size mismatch on %s:%s'\n", section, name); } - for (int i = 0; i < tokens.size(); i++) { + for (vector::size_type i = 0; i < tokens.size(); i++) { // need to parse into local variable to handle vector, // for which operator[] returns a special reference class // that's not the same as 'bool&', (since it's a packed @@ -286,7 +286,7 @@ arrayParamIn(Checkpoint *cp, const string §ion, param.resize(tokens.size()); - for (int i = 0; i < tokens.size(); i++) { + for (vector::size_type i = 0; i < tokens.size(); i++) { // need to parse into local variable to handle vector, // for which operator[] returns a special reference class // that's not the same as 'bool&', (since it's a packed @@ -306,8 +306,6 @@ arrayParamIn(Checkpoint *cp, const string §ion, } } - - void objParamIn(Checkpoint *cp, const string §ion, const string &name, SimObject * ¶m) @@ -326,10 +324,10 @@ paramIn(Checkpoint *cp, const string §ion, \ const string &name, type & param); \ template void \ arrayParamOut(ostream &os, const string &name, \ - type const *param, int size); \ + type const *param, unsigned size); \ template void \ arrayParamIn(Checkpoint *cp, const string §ion, \ - const string &name, type *param, int size); \ + const string &name, type *param, unsigned size); \ template void \ arrayParamOut(ostream &os, const string &name, \ const vector ¶m); \ diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 0069f5614..08240c0c0 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -59,7 +59,7 @@ void paramIn(Checkpoint *cp, const std::string §ion, template void arrayParamOut(std::ostream &os, const std::string &name, - const T *param, int size); + const T *param, unsigned size); template void arrayParamOut(std::ostream &os, const std::string &name, @@ -67,7 +67,7 @@ void arrayParamOut(std::ostream &os, const std::string &name, template void arrayParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, T *param, int size); + const std::string &name, T *param, unsigned size); template void arrayParamIn(Checkpoint *cp, const std::string §ion, diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 0d5bf1723..5f2ebd428 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -899,8 +899,7 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, uint64_t tiov_base = process->getSyscallArg(tc, 1); size_t count = process->getSyscallArg(tc, 2); struct iovec hiov[count]; - for (int i = 0; i < count; ++i) - { + for (size_t i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; p->readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), @@ -913,10 +912,8 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, int result = writev(process->sim_fd(fd), hiov, count); - for (int i = 0; i < count; ++i) - { + for (size_t i = 0; i < count; ++i) delete [] (char *)hiov[i].iov_base; - } if (result < 0) return -errno; diff --git a/src/sim/system.hh b/src/sim/system.hh index ab88160e2..aa89866bd 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -96,7 +96,7 @@ class System : public SimObject int numContexts() { - assert(_numContexts == threadContexts.size()); + assert(_numContexts == (int)threadContexts.size()); return _numContexts; } -- cgit v1.2.3