From f1d27bf667a8548121ed849cbb211eccf386f1bd Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 21 May 2013 23:33:54 +0200 Subject: wizard: fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .../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. --- Source/cmakewizard.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 749f669..8ac55d9 100644 --- a/Source/cmakewizard.cxx +++ b/Source/cmakewizard.cxx @@ -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(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(sizeof(buffer) - 1), stdin)) { buffer[0] = 0; } -- cgit v0.12