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.
This commit is contained in:
parent
6fc4cd8680
commit
ff1f8d0b53
|
@ -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; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
|
||||
for(size_t i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
|
||||
|
||||
int width;
|
||||
if (x < cmCursesMainForm::MAX_WIDTH )
|
||||
|
@ -76,8 +76,8 @@ void cmCursesLongMessageForm::UpdateStatusBar()
|
|||
char version[cmCursesMainForm::MAX_WIDTH];
|
||||
char vertmp[128];
|
||||
sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
|
||||
int sideSpace = (width-strlen(vertmp));
|
||||
for(int i=0; i<sideSpace; i++) { version[i] = ' '; }
|
||||
size_t sideSpace = (width-strlen(vertmp));
|
||||
for(size_t i=0; i<sideSpace; i++) { version[i] = ' '; }
|
||||
sprintf(version+sideSpace, "%s", vertmp);
|
||||
version[width] = '\0';
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
if (cw)
|
||||
{
|
||||
sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
|
||||
curses_move(0,65-strlen(firstLine)-1);
|
||||
curses_move(0,65-static_cast<unsigned int>(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; i<sideSpace; i++) { version[i] = ' '; }
|
||||
sprintf(version+sideSpace, "%s", vertmp);
|
||||
version[width] = '\0';
|
||||
|
@ -795,7 +795,7 @@ void cmCursesMainForm::RemoveEntry(const char* value)
|
|||
// copy from the list box to the cache manager
|
||||
void cmCursesMainForm::FillCacheManagerFromUI()
|
||||
{
|
||||
int size = this->Entries->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<unsigned int>(searchstr.size()));
|
||||
//curses_move(1,1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<char>::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<char>::size_type length = erriter-err.begin();
|
||||
if(length > 1 && *(erriter-1) == '\r')
|
||||
{
|
||||
--length;
|
||||
|
|
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue