GLog: Solve some compilation warnings

Those are actually sent to a pull-request, see

  https://github.com/google/glog/pull/81
This commit is contained in:
Sergey Sharybin 2015-12-30 17:25:54 +05:00
parent 6b7ead4fe8
commit 4145a4d08c
4 changed files with 14 additions and 8 deletions

@ -301,7 +301,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
#ifdef OS_WINDOWS #ifdef OS_WINDOWS
// Returns the character attribute for the given color. // Returns the character attribute for the given color.
WORD GetColorAttribute(GLogColor color) { static WORD GetColorAttribute(GLogColor color) {
switch (color) { switch (color) {
case COLOR_RED: return FOREGROUND_RED; case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN; case COLOR_GREEN: return FOREGROUND_GREEN;
@ -313,7 +313,7 @@ WORD GetColorAttribute(GLogColor color) {
#else #else
// Returns the ANSI color code for the given color. // Returns the ANSI color code for the given color.
const char* GetAnsiColorCode(GLogColor color) { static const char* GetAnsiColorCode(GLogColor color) {
switch (color) { switch (color) {
case COLOR_RED: return "1"; case COLOR_RED: return "1";
case COLOR_GREEN: return "2"; case COLOR_GREEN: return "2";
@ -1677,7 +1677,7 @@ void LogToStderr() {
namespace base { namespace base {
namespace internal { namespace internal {
bool GetExitOnDFatal() { static bool GetExitOnDFatal() {
MutexLock l(&log_mutex); MutexLock l(&log_mutex);
return exit_on_dfatal; return exit_on_dfatal;
} }
@ -1692,7 +1692,7 @@ bool GetExitOnDFatal() {
// and the stack trace is not recorded. The LOG(FATAL) *will* still // and the stack trace is not recorded. The LOG(FATAL) *will* still
// exit the program. Since this function is used only in testing, // exit the program. Since this function is used only in testing,
// these differences are acceptable. // these differences are acceptable.
void SetExitOnDFatal(bool value) { static void SetExitOnDFatal(bool value) {
MutexLock l(&log_mutex); MutexLock l(&log_mutex);
exit_on_dfatal = value; exit_on_dfatal = value;
} }

@ -634,7 +634,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
// bytes. Output will be truncated as needed, and a NUL character is always // bytes. Output will be truncated as needed, and a NUL character is always
// appended. // appended.
// NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc.
char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) { static char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
// Make sure we can write at least one NUL byte. // Make sure we can write at least one NUL byte.
size_t n = 1; size_t n = 1;
if (n > sz) if (n > sz)
@ -696,7 +696,7 @@ char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
// Safely appends string |source| to string |dest|. Never writes past the // Safely appends string |source| to string |dest|. Never writes past the
// buffer size |dest_size| and guarantees that |dest| is null-terminated. // buffer size |dest_size| and guarantees that |dest| is null-terminated.
void SafeAppendString(const char* source, char* dest, int dest_size) { static void SafeAppendString(const char* source, char* dest, int dest_size) {
int dest_string_length = strlen(dest); int dest_string_length = strlen(dest);
SAFE_ASSERT(dest_string_length < dest_size); SAFE_ASSERT(dest_string_length < dest_size);
dest += dest_string_length; dest += dest_string_length;
@ -709,7 +709,7 @@ void SafeAppendString(const char* source, char* dest, int dest_size) {
// Converts a 64-bit value into a hex string, and safely appends it to |dest|. // Converts a 64-bit value into a hex string, and safely appends it to |dest|.
// Never writes past the buffer size |dest_size| and guarantees that |dest| is // Never writes past the buffer size |dest_size| and guarantees that |dest| is
// null-terminated. // null-terminated.
void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) { static void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) {
// 64-bit numbers in hex can have up to 16 digits. // 64-bit numbers in hex can have up to 16 digits.
char buf[17] = {'\0'}; char buf[17] = {'\0'};
SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size); SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size);

@ -84,7 +84,7 @@ static void DebugWriteToStderr(const char* data, void *) {
} }
} }
void DebugWriteToString(const char* data, void *arg) { static void DebugWriteToString(const char* data, void *arg) {
reinterpret_cast<string*>(arg)->append(data); reinterpret_cast<string*>(arg)->append(data);
} }

@ -62,6 +62,12 @@ _START_GOOGLE_NAMESPACE_
namespace glog_internal_namespace_ { namespace glog_internal_namespace_ {
// Used by logging_unittests.cc so can't make it static here.
GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
size_t patt_len,
const char* str,
size_t str_len);
// Implementation of fnmatch that does not need 0-termination // Implementation of fnmatch that does not need 0-termination
// of arguments and does not allocate any memory, // of arguments and does not allocate any memory,
// but we only support "*" and "?" wildcards, not the "[...]" patterns. // but we only support "*" and "?" wildcards, not the "[...]" patterns.