wizard: fix warnings
.../Source/cmakewizard.cxx: In member function ‘virtual void cmakewizard::AskUser(const char*, cmCacheManager::CacheIterator&)’: .../Source/cmakewizard.cxx:31:35: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion] if(!fgets(buffer, sizeof(buffer)-1, stdin)) ^ .../Source/cmakewizard.cxx: In member function ‘virtual bool cmakewizard::AskAdvanced()’: .../Source/cmakewizard.cxx:70:35: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion] if(!fgets(buffer, sizeof(buffer)-1, stdin)) The compiler is (partly) right here: sizeof() returns a size_t, which often is bigger as as int as it is unsigned long or something similar. Add an explicit cast to get rid of that warning here, the buffer has a size of 4KiB, so the value will fit into an int on all sane platforms.
This commit is contained in:
parent
4825d70e83
commit
f1d27bf667
|
@ -28,7 +28,7 @@ void cmakewizard::AskUser(const char* key,
|
|||
printf("Current Value: %s\n", iter.GetValue());
|
||||
printf("New Value (Enter to keep current value): ");
|
||||
char buffer[4096];
|
||||
if(!fgets(buffer, sizeof(buffer)-1, stdin))
|
||||
if(!fgets(buffer, static_cast<int>(sizeof(buffer) - 1), stdin))
|
||||
{
|
||||
buffer[0] = 0;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ bool cmakewizard::AskAdvanced()
|
|||
{
|
||||
printf("Would you like to see advanced options? [No]:");
|
||||
char buffer[4096];
|
||||
if(!fgets(buffer, sizeof(buffer)-1, stdin))
|
||||
if(!fgets(buffer, static_cast<int>(sizeof(buffer) - 1), stdin))
|
||||
{
|
||||
buffer[0] = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue