From: Date: Wed, 8 Jul 2009 17:19:09 +0000 (+0000) Subject: Suppress warnings. Most of this patch was given by keir (thanks!). X-Git-Tag: accepted/tizen/5.0/unified/20181102.024921~180 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c4e3a9238a433b709c2fe172bc29d80c4f275b3;p=platform%2Fupstream%2Fglog.git Suppress warnings. Most of this patch was given by keir (thanks!). Corresponding glog bug: http://code.google.com/p/google-glog/issues/detail?id=10 The differences from keir's patch are: - For raw_logging.h.in, I just included time.h for struct tm. - Added a fprintf which warns that we should have died to avoid a warning for unused local variable. - Added inline for some functions which may be unused in googletest.h. - Removed DumpPCAndFrameSize as it was unused. git-svn-id: https://google-glog.googlecode.com/svn/trunk@56 eb4d4688-79bd-11dd-afb4-1d65580434c0 --- diff --git a/src/glog/raw_logging.h.in b/src/glog/raw_logging.h.in index f20c3a9..5378cd4 100644 --- a/src/glog/raw_logging.h.in +++ b/src/glog/raw_logging.h.in @@ -36,6 +36,8 @@ #ifndef BASE_RAW_LOGGING_H_ #define BASE_RAW_LOGGING_H_ +#include + @ac_google_start_namespace@ #include "glog/log_severity.h" @@ -176,8 +178,7 @@ GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity, // Hack to propagate time information into this module so that // this module does not have to directly call localtime_r(), // which could allocate memory. -extern "C" struct ::tm; -GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct ::tm& t, int usecs); +GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs); @ac_google_end_namespace@ diff --git a/src/googletest.h b/src/googletest.h index 183c56b..09f18fc 100644 --- a/src/googletest.h +++ b/src/googletest.h @@ -71,7 +71,7 @@ _END_GOOGLE_NAMESPACE_ #undef GOOGLE_GLOG_DLL_DECL #define GOOGLE_GLOG_DLL_DECL -static string GetTempDir() { +static inline string GetTempDir() { #ifndef OS_WINDOWS return "/tmp"; #else @@ -180,7 +180,7 @@ vector g_testlist; // the tests to run void Test_##a##_##b::RunTest() -static int RUN_ALL_TESTS() { +static inline int RUN_ALL_TESTS() { vector::const_iterator it; for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { (*it)(); @@ -197,7 +197,7 @@ _START_GOOGLE_NAMESPACE_ static bool g_called_abort; static jmp_buf g_jmp_buf; -static void CalledAbort() { +static inline void CalledAbort() { g_called_abort = true; longjmp(g_jmp_buf, 1); } @@ -241,7 +241,7 @@ class BenchmarkRegisterer { } }; -static void RunSpecifiedBenchmarks() { +static inline void RunSpecifiedBenchmarks() { if (!FLAGS_run_benchmark) { return; } @@ -319,21 +319,21 @@ static CapturedStream * s_captured_streams[STDERR_FILENO+1]; // Redirect a file descriptor to a file. // fd - Should be STDOUT_FILENO or STDERR_FILENO // filename - File where output should be stored -static void CaptureTestOutput(int fd, const string & filename) { +static inline void CaptureTestOutput(int fd, const string & filename) { CHECK((fd == STDOUT_FILENO) || (fd == STDERR_FILENO)); CHECK(s_captured_streams[fd] == NULL); s_captured_streams[fd] = new CapturedStream(fd, filename); } -static void CaptureTestStderr() { +static inline void CaptureTestStderr() { CaptureTestOutput(STDERR_FILENO, FLAGS_test_tmpdir + "/captured.err"); } // Return the size (in bytes) of a file -static size_t GetFileSize(FILE * file) { +static inline size_t GetFileSize(FILE * file) { fseek(file, 0, SEEK_END); return static_cast(ftell(file)); } // Read the entire content of a file as a string -static string ReadEntireFile(FILE * file) { +static inline string ReadEntireFile(FILE * file) { const size_t file_size = GetFileSize(file); char * const buffer = new char[file_size]; @@ -356,7 +356,7 @@ static string ReadEntireFile(FILE * file) { } // Get the captured stdout (when fd is STDOUT_FILENO) or stderr (when // fd is STDERR_FILENO) as a string -static string GetCapturedTestOutput(int fd) { +static inline string GetCapturedTestOutput(int fd) { CHECK(fd == STDOUT_FILENO || fd == STDERR_FILENO); CapturedStream * const cap = s_captured_streams[fd]; CHECK(cap) @@ -376,12 +376,12 @@ static string GetCapturedTestOutput(int fd) { return content; } // Get the captured stderr of a test as a string. -static string GetCapturedTestStderr() { +static inline string GetCapturedTestStderr() { return GetCapturedTestOutput(STDERR_FILENO); } // Check if the string is [IWEF](\d{4}|DATE) -static bool IsLoggingPrefix(const string& s) { +static inline bool IsLoggingPrefix(const string& s) { if (s.size() != 5) return false; if (!strchr("IWEF", s[0])) return false; for (int i = 1; i <= 4; ++i) { @@ -395,7 +395,7 @@ static bool IsLoggingPrefix(const string& s) { // Example: // I0102 030405 logging_unittest.cc:345] RAW: vlog -1 // => IDATE TIME__ logging_unittest.cc:LINE] RAW: vlog -1 -static string MungeLine(const string& line) { +static inline string MungeLine(const string& line) { std::istringstream iss(line); string before, logcode_date, time, thread_lineinfo; iss >> logcode_date; @@ -427,7 +427,7 @@ static string MungeLine(const string& line) { MungeLine(rest)); } -static void StringReplace(string* str, +static inline void StringReplace(string* str, const string& oldsub, const string& newsub) { size_t pos = str->find(oldsub); @@ -436,7 +436,7 @@ static void StringReplace(string* str, } } -static string Munge(const string& filename) { +static inline string Munge(const string& filename) { FILE* fp = fopen(filename.c_str(), "rb"); CHECK(fp != NULL) << filename << ": couldn't open"; char buf[4096]; @@ -444,7 +444,7 @@ static string Munge(const string& filename) { while (fgets(buf, 4095, fp)) { string line = MungeLine(buf); char null_str[256]; - sprintf(null_str, "%p", NULL); + sprintf(null_str, "%p", static_cast(NULL)); StringReplace(&line, "__NULLP__", null_str); // Remove 0x prefix produced by %p. VC++ doesn't put the prefix. StringReplace(&line, " 0x", " "); @@ -468,13 +468,13 @@ static string Munge(const string& filename) { return result; } -static void WriteToFile(const string& body, const string& file) { +static inline void WriteToFile(const string& body, const string& file) { FILE* fp = fopen(file.c_str(), "wb"); fwrite(body.data(), 1, body.size(), fp); fclose(fp); } -static bool MungeAndDiffTestStderr(const string& golden_filename) { +static inline bool MungeAndDiffTestStderr(const string& golden_filename) { CapturedStream* cap = s_captured_streams[STDERR_FILENO]; CHECK(cap) << ": did you forget CaptureTestStderr()?"; @@ -567,7 +567,7 @@ class Thread { #endif }; -static void SleepForMilliseconds(int t) { +static inline void SleepForMilliseconds(int t) { #ifndef OS_WINDOWS usleep(t * 1000); #else diff --git a/src/signalhandler.cc b/src/signalhandler.cc index 7090399..8d9ab4b 100644 --- a/src/signalhandler.cc +++ b/src/signalhandler.cc @@ -232,7 +232,8 @@ void DumpStackFrameInfo(const char* prefix, void* pc) { // Invoke the default signal handler. void InvokeDefaultSignalHandler(int signal_number) { - struct sigaction sig_action = {}; // Zero-clear. + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); sigemptyset(&sig_action.sa_mask); sig_action.sa_handler = SIG_DFL; sigaction(signal_number, &sig_action, NULL); @@ -326,7 +327,8 @@ void FailureSignalHandler(int signal_number, void InstallFailureSignalHandler() { // Build the sigaction struct. - struct sigaction sig_action = {}; // Zero-clear. + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); sigemptyset(&sig_action.sa_mask); sig_action.sa_flags |= SA_SIGINFO; sig_action.sa_sigaction = &FailureSignalHandler; diff --git a/src/signalhandler_unittest.cc b/src/signalhandler_unittest.cc index 38a54bc..05a5b96 100644 --- a/src/signalhandler_unittest.cc +++ b/src/signalhandler_unittest.cc @@ -48,6 +48,8 @@ void* DieInThread(void*) { // Use volatile to prevent from these to be optimized away. volatile int a = 0; volatile int b = 1 / a; + fprintf(stderr, "We should have died: b=%d\n", b); + return NULL; } void WriteToStdout(const char* data, int size) { diff --git a/src/symbolize_unittest.cc b/src/symbolize_unittest.cc index 77dfb29..f25909d 100644 --- a/src/symbolize_unittest.cc +++ b/src/symbolize_unittest.cc @@ -193,7 +193,8 @@ static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) { memset(altstack, kAlternateStackFillValue, kAlternateStackSize); // Set up the alt-signal-stack (and save the older one). - stack_t sigstk = {}; // Zero-clear. + stack_t sigstk; + memset(&sigstk, 0, sizeof(stack_t)); stack_t old_sigstk; sigstk.ss_sp = altstack; sigstk.ss_size = kAlternateStackSize; @@ -201,7 +202,8 @@ static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) { CHECK_ERR(sigaltstack(&sigstk, &old_sigstk)); // Set up SIGUSR1 and SIGUSR2 signal handlers (and save the older ones). - struct sigaction sa = {}; // Zero-clear; + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); struct sigaction old_sa1, old_sa2; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_ONSTACK; diff --git a/src/utilities.h b/src/utilities.h index dc4c6d1..6ab7f5c 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -44,6 +44,8 @@ # define OS_MACOSX #elif defined(__FreeBSD__) # define OS_FREEBSD +#elif defined(__OpenBSD__) +# define OS_OPENBSD #else // TODO(hamaji): Add other platforms. #endif diff --git a/src/windows/glog/raw_logging.h b/src/windows/glog/raw_logging.h index 37e327f..c81e67b 100755 --- a/src/windows/glog/raw_logging.h +++ b/src/windows/glog/raw_logging.h @@ -40,6 +40,8 @@ #ifndef BASE_RAW_LOGGING_H_ #define BASE_RAW_LOGGING_H_ +#include + namespace google { #include "glog/log_severity.h" @@ -180,8 +182,7 @@ GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity, // Hack to propagate time information into this module so that // this module does not have to directly call localtime_r(), // which could allocate memory. -extern "C" struct ::tm; -GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct ::tm& t, int usecs); +GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs); }