-rw-r--r-- | src/eyetil.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc index 2e6ab7e..11e2fb7 100644 --- a/src/eyetil.cc +++ b/src/eyetil.cc @@ -17,16 +17,16 @@ binary_t& binary_t::from_hex(const std::string& h) { std::string::size_type hs = h.length(); if(hs&1) throw std::runtime_error("odd number of characters in hexadecimal number"); - int rvs = hs>>1; + size_t rvs = hs>>1; resize(rvs); const unsigned char *hp = (const unsigned char*)h.data(); iterator oi=begin(); char t[3] = { 0,0,0 }; - for(int i=0;i<rvs;++i) { + for(size_t i=0;i<rvs;++i) { t[0]=*(hp++); t[1]=*(hp++); - *(oi++) = strtol(t,0,16); + *(oi++) = static_cast<binary_t::value_type>(0xff&strtol(t,0,16)); } return *this; } @@ -53,9 +53,9 @@ std::string binary_t::hex() const { std::string rv; rv.reserve((size()<<1)+1); char t[3] = {0,0,0}; for(const_iterator i=begin(),ie=end();i!=ie;++i) { - int rc = snprintf(t,sizeof(t),"%02x",*i); + size_t rc = snprintf(t,sizeof(t),"%02x",*i); assert(rc<sizeof(t)); rv += t; } return rv; @@ -157,9 +157,9 @@ struct block512_t { static uint16_t tcpcksum(block512_t& data) { uint32_t sum = std::accumulate(data.data,data.data+words,0); while(uint32_t hw = sum>>16) sum = (sum&0xffff)+hw; - return ~sum; + return 0xffff&~sum; } }; #pragma pack() |