Remove trivial warnings produced by clang

git-svn-id: https://google-glog.googlecode.com/svn/trunk@107 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
2012-01-12 08:41:09 +00:00
parent cd026f9eab
commit 73b0abc989
14 changed files with 34 additions and 33 deletions

View File

@ -36,7 +36,7 @@
class GoogleInitializer { class GoogleInitializer {
public: public:
typedef void (*void_function)(void); typedef void (*void_function)(void);
GoogleInitializer(const char* name, void_function f) { GoogleInitializer(const char*, void_function f) {
f(); f();
} }
}; };

View File

@ -237,7 +237,7 @@ static bool ParseCharClass(State *state, const char *char_class) {
} }
// This function is used for handling an optional non-terminal. // This function is used for handling an optional non-terminal.
static bool Optional(bool status) { static bool Optional(bool) {
return true; return true;
} }
@ -400,7 +400,7 @@ static void MaybeCancelLastSeparator(State *state) {
// "mangled_cur" is anonymous namespace. // "mangled_cur" is anonymous namespace.
static bool IdentifierIsAnonymousNamespace(State *state, int length) { static bool IdentifierIsAnonymousNamespace(State *state, int length) {
static const char anon_prefix[] = "_GLOBAL__N_"; static const char anon_prefix[] = "_GLOBAL__N_";
return (length > sizeof(anon_prefix) - 1 && // Should be longer. return (length > (int)sizeof(anon_prefix) - 1 && // Should be longer.
StrPrefix(state->mangled_cur, anon_prefix)); StrPrefix(state->mangled_cur, anon_prefix));
} }

View File

@ -1485,7 +1485,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
// converted to LogStream and the message will be computed and then // converted to LogStream and the message will be computed and then
// quietly discarded. // quietly discarded.
template<class T> template<class T>
inline NullStream& operator<<(NullStream &str, const T &value) { return str; } inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// Similar to NullStream, but aborts the program (without stack // Similar to NullStream, but aborts the program (without stack
// trace), like LogMessageFatal. // trace), like LogMessageFatal.

View File

@ -110,7 +110,7 @@ using testing::InitGoogleTest;
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
void InitGoogleTest(int* argc, char** argv) {} void InitGoogleTest(int*, char**) {}
// The following is some bare-bones testing infrastructure // The following is some bare-bones testing infrastructure
@ -528,7 +528,7 @@ class Thread {
public: public:
virtual ~Thread() {} virtual ~Thread() {}
void SetJoinable(bool joinable) {} void SetJoinable(bool) {}
#if defined(OS_WINDOWS) || defined(OS_CYGWIN) #if defined(OS_WINDOWS) || defined(OS_CYGWIN)
void Start() { void Start() {
handle_ = CreateThread(NULL, handle_ = CreateThread(NULL,

View File

@ -1564,7 +1564,7 @@ static void GetTempDirectories(vector<string>* list) {
"/tmp", "/tmp",
}; };
for (int i = 0; i < ARRAYSIZE(candidates); i++) { for (size_t i = 0; i < ARRAYSIZE(candidates); i++) {
const char *d = candidates[i]; const char *d = candidates[i];
if (!d) continue; // Empty env var if (!d) continue; // Empty env var

View File

@ -56,7 +56,7 @@ int CheckNoReturn(bool b) {
struct A { }; struct A { };
std::ostream &operator<<(std::ostream &str, const A&) {return str;} std::ostream &operator<<(std::ostream &str, const A&) {return str;}
int main(int argc, char* argv[]) { int main(int, char* argv[]) {
FLAGS_logtostderr = true; FLAGS_logtostderr = true;
InitGoogleLogging(argv[0]); InitGoogleLogging(argv[0]);
if (FLAGS_check_mode) { if (FLAGS_check_mode) {

View File

@ -155,7 +155,8 @@ static void BM_Check2(int n) {
} }
BENCHMARK(BM_Check2); BENCHMARK(BM_Check2);
static void CheckFailure(int a, int b, const char* file, int line, const char* msg) { static void CheckFailure(int, int, const char* /* file */, int /* line */,
const char* /* msg */) {
} }
static void BM_logspeed(int n) { static void BM_logspeed(int n) {
@ -471,7 +472,7 @@ void TestLogToString() {
class TestLogSinkImpl : public LogSink { class TestLogSinkImpl : public LogSink {
public: public:
vector<string> errors; vector<string> errors;
virtual void send(LogSeverity severity, const char* full_filename, virtual void send(LogSeverity severity, const char* /* full_filename */,
const char* base_filename, int line, const char* base_filename, int line,
const struct tm* tm_time, const struct tm* tm_time,
const char* message, size_t message_len) { const char* message, size_t message_len) {
@ -610,7 +611,7 @@ static void GetFiles(const string& pattern, vector<string>* files) {
glob_t g; glob_t g;
const int r = glob(pattern.c_str(), 0, NULL, &g); const int r = glob(pattern.c_str(), 0, NULL, &g);
CHECK((r == 0) || (r == GLOB_NOMATCH)) << ": error matching " << pattern; CHECK((r == 0) || (r == GLOB_NOMATCH)) << ": error matching " << pattern;
for (int i = 0; i < g.gl_pathc; i++) { for (size_t i = 0; i < g.gl_pathc; i++) {
files->push_back(string(g.gl_pathv[i])); files->push_back(string(g.gl_pathv[i]));
} }
globfree(&g); globfree(&g);
@ -647,7 +648,7 @@ static void DeleteFiles(const string& pattern) {
static void CheckFile(const string& name, const string& expected_string) { static void CheckFile(const string& name, const string& expected_string) {
vector<string> files; vector<string> files;
GetFiles(name + "*", &files); GetFiles(name + "*", &files);
CHECK_EQ(files.size(), 1); CHECK_EQ(files.size(), 1UL);
FILE* file = fopen(files[0].c_str(), "r"); FILE* file = fopen(files[0].c_str(), "r");
CHECK(file != NULL) << ": could not open " << files[0]; CHECK(file != NULL) << ": could not open " << files[0];
@ -711,7 +712,7 @@ static void TestExtension() {
// Check that file name ends with extension // Check that file name ends with extension
vector<string> filenames; vector<string> filenames;
GetFiles(dest + "*", &filenames); GetFiles(dest + "*", &filenames);
CHECK_EQ(filenames.size(), 1); CHECK_EQ(filenames.size(), 1UL);
CHECK(strstr(filenames[0].c_str(), "specialextension") != NULL); CHECK(strstr(filenames[0].c_str(), "specialextension") != NULL);
// Release file handle for the destination file to unlock the file in Windows. // Release file handle for the destination file to unlock the file in Windows.
@ -722,8 +723,8 @@ static void TestExtension() {
struct MyLogger : public base::Logger { struct MyLogger : public base::Logger {
string data; string data;
virtual void Write(bool should_flush, virtual void Write(bool /* should_flush */,
time_t timestamp, time_t /* timestamp */,
const char* message, const char* message,
int length) { int length) {
data.append(message, length); data.append(message, length);
@ -991,7 +992,7 @@ class TestWaitingLogSink : public LogSink {
// (re)define LogSink interface // (re)define LogSink interface
virtual void send(LogSeverity severity, const char* full_filename, virtual void send(LogSeverity severity, const char* /* full_filename */,
const char* base_filename, int line, const char* base_filename, int line,
const struct tm* tm_time, const struct tm* tm_time,
const char* message, size_t message_len) { const char* message, size_t message_len) {
@ -1030,7 +1031,7 @@ static void TestLogSinkWaitTillSent() {
for (size_t i = 0; i < global_messages.size(); ++i) { for (size_t i = 0; i < global_messages.size(); ++i) {
LOG(INFO) << "Sink capture: " << global_messages[i]; LOG(INFO) << "Sink capture: " << global_messages[i];
} }
CHECK_EQ(global_messages.size(), 3); CHECK_EQ(global_messages.size(), 3UL);
} }
TEST(Strerror, logging) { TEST(Strerror, logging) {
@ -1190,10 +1191,10 @@ TEST(LogBacktraceAt, DoesBacktraceAtRightLineWhenEnabled) {
#endif // HAVE_LIB_GMOCK #endif // HAVE_LIB_GMOCK
struct UserDefinedClass { struct UserDefinedClass {
bool operator==(const UserDefinedClass& rhs) const { return true; } bool operator==(const UserDefinedClass&) const { return true; }
}; };
inline ostream& operator<<(ostream& out, const UserDefinedClass& u) { inline ostream& operator<<(ostream& out, const UserDefinedClass&) {
out << "OK"; out << "OK";
return out; return out;
} }
@ -1202,7 +1203,7 @@ TEST(UserDefinedClass, logging) {
UserDefinedClass u; UserDefinedClass u;
vector<string> buf; vector<string> buf;
LOG_STRING(INFO, &buf) << u; LOG_STRING(INFO, &buf) << u;
CHECK_EQ(1, buf.size()); CHECK_EQ(1UL, buf.size());
CHECK(buf[0].find("OK") != string::npos); CHECK(buf[0].find("OK") != string::npos);
// We must be able to compile this. // We must be able to compile this.

View File

@ -169,7 +169,7 @@ void DumpTimeInfo() {
void DumpSignalInfo(int signal_number, siginfo_t *siginfo) { void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
// Get the signal name. // Get the signal name.
const char* signal_name = NULL; const char* signal_name = NULL;
for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
if (signal_number == kFailureSignals[i].number) { if (signal_number == kFailureSignals[i].number) {
signal_name = kFailureSignals[i].name; signal_name = kFailureSignals[i].name;
} }
@ -338,7 +338,7 @@ void InstallFailureSignalHandler() {
sig_action.sa_flags |= SA_SIGINFO; sig_action.sa_flags |= SA_SIGINFO;
sig_action.sa_sigaction = &FailureSignalHandler; sig_action.sa_sigaction = &FailureSignalHandler;
for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL)); CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
} }
} }

View File

@ -190,7 +190,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace(int i) {
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
int main(int argc, char ** argv) { int main(int, char ** argv) {
FLAGS_logtostderr = true; FLAGS_logtostderr = true;
InitGoogleLogging(argv[0]); InitGoogleLogging(argv[0]);

View File

@ -170,7 +170,7 @@ void TestSTLLogging() {
#endif #endif
} }
int main(int argc, char** argv) { int main(int, char**) {
TestSTLLogging(); TestSTLLogging();
std::cout << "PASS\n"; std::cout << "PASS\n";
return 0; return 0;
@ -180,7 +180,7 @@ int main(int argc, char** argv) {
#include <iostream> #include <iostream>
int main(int argc, char** argv) { int main(int, char**) {
std::cout << "We don't support stl_logging for this compiler.\n" std::cout << "We don't support stl_logging for this compiler.\n"
<< "(we need compiler support of 'using ::operator<<' " << "(we need compiler support of 'using ::operator<<' "
<< "for this feature.)\n"; << "for this feature.)\n";

View File

@ -82,8 +82,8 @@ static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, int out_size) {
char demangled[256]; // Big enough for sane demangled symbols. char demangled[256]; // Big enough for sane demangled symbols.
if (Demangle(out, demangled, sizeof(demangled))) { if (Demangle(out, demangled, sizeof(demangled))) {
// Demangling succeeded. Copy to out if the space allows. // Demangling succeeded. Copy to out if the space allows.
int len = strlen(demangled); size_t len = strlen(demangled);
if (len + 1 <= out_size) { // +1 for '\0'. if (len + 1 <= (size_t)out_size) { // +1 for '\0'.
SAFE_ASSERT(len < sizeof(demangled)); SAFE_ASSERT(len < sizeof(demangled));
memmove(out, demangled, len + 1); memmove(out, demangled, len + 1);
} }
@ -637,7 +637,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
int out_size) { int out_size) {
Dl_info info; Dl_info info;
if (dladdr(pc, &info)) { if (dladdr(pc, &info)) {
if (strlen(info.dli_sname) < out_size) { if ((int)strlen(info.dli_sname) < out_size) {
strcpy(out, info.dli_sname); strcpy(out, info.dli_sname);
// Symbolization succeeded. Now we try to demangle the symbol. // Symbolization succeeded. Now we try to demangle the symbol.
DemangleInplace(out, out_size); DemangleInplace(out, out_size);

View File

@ -77,7 +77,7 @@ typedef void DebugWriter(const char*, void*);
// For some environments, add two extra bytes for the leading "0x". // For some environments, add two extra bytes for the leading "0x".
static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*); static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
static void DebugWriteToStderr(const char* data, void *unused) { static void DebugWriteToStderr(const char* data, void *) {
// This one is signal-safe. // This one is signal-safe.
if (write(STDERR_FILENO, data, strlen(data)) < 0) { if (write(STDERR_FILENO, data, strlen(data)) < 0) {
// Ignore errors. // Ignore errors.

View File

@ -70,8 +70,8 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
size_t patt_len, size_t patt_len,
const char* str, const char* str,
size_t str_len) { size_t str_len) {
int p = 0; size_t p = 0;
int s = 0; size_t s = 0;
while (1) { while (1) {
if (p == patt_len && s == str_len) return true; if (p == patt_len && s == str_len) return true;
if (p == patt_len) return false; if (p == patt_len) return false;
@ -211,7 +211,7 @@ bool InitVLOG3__(int32** site_flag, int32* site_default,
const char* base = strrchr(fname, '/'); const char* base = strrchr(fname, '/');
base = base ? (base+1) : fname; base = base ? (base+1) : fname;
const char* base_end = strchr(base, '.'); const char* base_end = strchr(base, '.');
size_t base_length = base_end ? (base_end - base) : strlen(base); size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
// Trim out trailing "-inl" if any // Trim out trailing "-inl" if any
if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) { if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {

View File

@ -1489,7 +1489,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
// converted to LogStream and the message will be computed and then // converted to LogStream and the message will be computed and then
// quietly discarded. // quietly discarded.
template<class T> template<class T>
inline NullStream& operator<<(NullStream &str, const T &value) { return str; } inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// Similar to NullStream, but aborts the program (without stack // Similar to NullStream, but aborts the program (without stack
// trace), like LogMessageFatal. // trace), like LogMessageFatal.