diff options
author | Brad King <brad.king@kitware.com> | 2010-08-11 13:47:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-08-11 13:47:04 (GMT) |
commit | 4663356079da1c578ab0f7762b4c9d87327b80c3 (patch) | |
tree | 27f81404cf94fedd7a8f7a82d036e7489b07ba06 /Source/cmArchiveWrite.cxx | |
parent | aef672311aa8b802c4477a4d51f531f752a6a787 (diff) | |
download | CMake-4663356079da1c578ab0f7762b4c9d87327b80c3.zip CMake-4663356079da1c578ab0f7762b4c9d87327b80c3.tar.gz CMake-4663356079da1c578ab0f7762b4c9d87327b80c3.tar.bz2 |
cmArchiveWrite: Fix signed/unsigned again
Some stream libraries return size_t from gcount() and some return
ssize_t. Add an explicit cast to ios::streamsize for its return value.
Also refactor use of nnext to reduce the use of casts.
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 88874aa..94c97e6 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -216,24 +216,24 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) size_t nleft = size; while(nleft > 0) { - cmsys_ios::streamsize nnext = static_cast<cmsys_ios::streamsize>( - nleft > sizeof(buffer)? sizeof(buffer) : nleft); - fin.read(buffer, nnext); + typedef cmsys_ios::streamsize ssize_type; + size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft; + ssize_type const nnext_s = static_cast<ssize_type>(nnext); + fin.read(buffer, nnext_s); // Some stream libraries (older HPUX) return failure at end of // file on the last read even if some data were read. Check // gcount instead of trusting the stream error status. - if(fin.gcount() != nnext) + if(static_cast<size_t>(fin.gcount()) != nnext) { break; } - if(archive_write_data(this->Archive, buffer, - static_cast<size_t>(nnext)) != nnext) + if(archive_write_data(this->Archive, buffer, nnext) != nnext_s) { this->Error = "archive_write_data: "; this->Error += archive_error_string(this->Archive); return false; } - nleft -= static_cast<size_t>(nnext); + nleft -= nnext; } if(nleft > 0) { |