From ff1f8d0b53c37336645d4d53fc30134540d17ddd Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jun 2010 09:52:12 -0400 Subject: Fix or cast more integer conversions in cmake These were revealed by GCC's -Wconversion option. Fix types where it is easy to do so. Cast in cases we know the integer will not be truncated. --- Source/CursesDialog/cmCursesLongMessageForm.cxx | 8 ++++---- Source/CursesDialog/cmCursesMainForm.cxx | 12 ++++++------ Source/CursesDialog/cmCursesMainForm.h | 2 +- Source/cmCTest.cxx | 4 ++-- Source/cmSystemTools.cxx | 8 ++++---- Source/cm_utf8.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index c66147b..1c48d8c 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -53,13 +53,13 @@ void cmCursesLongMessageForm::UpdateStatusBar() getmaxyx(stdscr, y, x); char bar[cmCursesMainForm::MAX_WIDTH]; - int size = strlen(this->Title.c_str()); + size_t size = strlen(this->Title.c_str()); if ( size >= cmCursesMainForm::MAX_WIDTH ) { size = cmCursesMainForm::MAX_WIDTH-1; } strncpy(bar, this->Title.c_str(), size); - for(int i=size-1; iGetPage(), this->NumberOfPages); - curses_move(0,65-strlen(firstLine)-1); + curses_move(0,65-static_cast(strlen(firstLine))-1); printw(firstLine); } // } @@ -526,8 +526,8 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) // Join the key, help string and pad with spaces // (or truncate) as necessary char bar[cmCursesMainForm::MAX_WIDTH]; - int i, curFieldLen = strlen(curField); - int helpLen = strlen(help); + size_t i, curFieldLen = strlen(curField); + size_t helpLen = strlen(help); int width; if (x < cmCursesMainForm::MAX_WIDTH ) @@ -592,7 +592,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion()); - int sideSpace = (width-strlen(vertmp)); + size_t sideSpace = (width-strlen(vertmp)); for(i=0; iEntries->size(); + size_t size = this->Entries->size(); for(int i=0; i < size; i++) { cmCacheManager::CacheIterator it = @@ -866,7 +866,7 @@ void cmCursesMainForm::HandleInput() std::string searchstr = "Search: " + this->SearchString; this->UpdateStatusBar( searchstr.c_str() ); this->PrintKeys(1); - curses_move(y-5,searchstr.size()); + curses_move(y-5,static_cast(searchstr.size())); //curses_move(1,1); touchwin(stdscr); refresh(); diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 9751999..4084415 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -147,7 +147,7 @@ protected: // Where is cmake executable std::string WhereCMake; // Number of entries shown (depends on mode -normal or advanced-) - int NumberOfVisibleEntries; + size_t NumberOfVisibleEntries; bool AdvancedMode; // Did the iteration converge (no new entries) ? bool OkToGenerate; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bd69d6c..4d56257 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1169,7 +1169,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, if ( tick % tick_line_len == 0 && tick > 0 ) { cmCTestLog(this, HANDLER_OUTPUT, " Size: " - << int((output->size() / 1024.0) + 1) << "K" << std::endl + << int((double(output->size()) / 1024.0) + 1) << "K" << std::endl << " " << std::flush); } } @@ -1181,7 +1181,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, } } cmCTestLog(this, OUTPUT, " Size of output: " - << int(output->size() / 1024.0) << "K" << std::endl); + << int(double(output->size()) / 1024.0) << "K" << std::endl); cmsysProcess_WaitForExit(cp, 0); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5be53c2..0badbba 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1989,9 +1989,9 @@ namespace{ # pragma warn -8066 /* unreachable code */ #endif -int copy_data(struct archive *ar, struct archive *aw) +long copy_data(struct archive *ar, struct archive *aw) { - int r; + long r; const void *buff; size_t size; off_t offset; @@ -2136,7 +2136,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*outiter == '\n' || *outiter == '\0') { - int length = outiter-out.begin(); + std::vector::size_type length = outiter-out.begin(); if(length > 1 && *(outiter-1) == '\r') { --length; @@ -2159,7 +2159,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*erriter == '\n' || *erriter == '\0') { - int length = erriter-err.begin(); + std::vector::size_type length = erriter-err.begin(); if(length > 1 && *(erriter-1) == '\r') { --length; diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c index 9c11f2b..c9bf259 100644 --- a/Source/cm_utf8.c +++ b/Source/cm_utf8.c @@ -62,7 +62,7 @@ const char* cm_utf8_decode_character(const char* first, const char* last, /* Extract bits from this multi-byte character. */ { unsigned int uc = c & cm_utf8_mask[ones]; - unsigned char left; + int left; for(left = ones-1; left && first != last; --left) { c = (unsigned char)*first++; -- cgit v0.12