From aef672311aa8b802c4477a4d51f531f752a6a787 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 9 Aug 2010 10:30:41 -0400 Subject: 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. --- Source/cmArchiveWrite.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 0a44168..88874aa 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -12,6 +12,7 @@ #include "cmArchiveWrite.h" #include "cmSystemTools.h" +#include #include #include @@ -33,7 +34,8 @@ struct cmArchiveWrite::Callback const void *b, size_t n) { cmArchiveWrite* self = static_cast(cd); - if(self->Stream.write(static_cast(b), n)) + if(self->Stream.write(static_cast(b), + static_cast(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( + 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(nnext)) != nnext) { this->Error = "archive_write_data: "; this->Error += archive_error_string(this->Archive); return false; } - nleft -= nnext; + nleft -= static_cast(nnext); } if(nleft > 0) { -- cgit v0.12