diff options
author | Brad King <brad.king@kitware.com> | 2010-08-09 10:30:41 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-08-09 10:43:03 -0400 |
commit | aef672311aa8b802c4477a4d51f531f752a6a787 (patch) | |
tree | 46bb1ae095b49e62f629a787a96eb1dad2bea21a /Source/cmArchiveWrite.cxx | |
parent | 1b5b2ed3b2c458b25523342f3f32cb2a6368b1f5 (diff) | |
download | cmake-aef672311aa8b802c4477a4d51f531f752a6a787.tar.gz |
cmArchiveWrite: Fix signed/unsigned compare/convert
The libarchive interface accepts size_t but returns ssize_t. The std
streams interface wants streamsize, which is typically ssize_t. Since
no one type for our variable matches without conversions, make the
conversions explicit to avoid -Wsign-conversion and -Wsign-compare
warnings.
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 0a44168241..88874aa6e9 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -12,6 +12,7 @@ #include "cmArchiveWrite.h" #include "cmSystemTools.h" +#include <cmsys/ios/iostream> #include <cmsys/Directory.hxx> #include <cm_libarchive.h> @@ -33,7 +34,8 @@ struct cmArchiveWrite::Callback const void *b, size_t n) { cmArchiveWrite* self = static_cast<cmArchiveWrite*>(cd); - if(self->Stream.write(static_cast<const char*>(b), n)) + if(self->Stream.write(static_cast<const char*>(b), + static_cast<cmsys_ios::streamsize>(n))) { return static_cast<__LA_SSIZE_T>(n); } @@ -214,7 +216,8 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) size_t nleft = size; while(nleft > 0) { - size_t nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft; + cmsys_ios::streamsize nnext = static_cast<cmsys_ios::streamsize>( + nleft > sizeof(buffer)? sizeof(buffer) : nleft); fin.read(buffer, nnext); // Some stream libraries (older HPUX) return failure at end of // file on the last read even if some data were read. Check @@ -223,13 +226,14 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) { break; } - if(archive_write_data(this->Archive, buffer, nnext) != nnext) + if(archive_write_data(this->Archive, buffer, + static_cast<size_t>(nnext)) != nnext) { this->Error = "archive_write_data: "; this->Error += archive_error_string(this->Archive); return false; } - nleft -= nnext; + nleft -= static_cast<size_t>(nnext); } if(nleft > 0) { |