-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 @@ -13,24 +13,24 @@ #ifdef HAVE_LIBUUID # include <uuid/uuid.h> #endif 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; } binary_t& binary_t::from_data(const void *d,size_t s) { resize(s); std::copy((const unsigned char*)d,(const unsigned char *)d+s, begin() ); @@ -49,17 +49,17 @@ binary_t& binary_t::make_nonce() { return *this; } 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; } binary_t binary_t::md5() const { binary_t rv(MD5_DIGEST_LENGTH); @@ -153,17 +153,17 @@ bool tarchive_t::read_data_into_fd(int fd) { #pragma pack(1) struct block512_t { enum { words = 512 / sizeof(uint16_t) }; uint16_t data[words]; 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() binary_t integrity_digest(const void *ptr,size_t size,const std::string& ukey) { md5_digester rv; std::transform( (block512_t*)ptr, ((block512_t*)ptr)+size/sizeof(block512_t), |