Commit f94a49c5 authored by Sergey Sharybin's avatar Sergey Sharybin

Resolve missing prototype warning

Makes compilation process less noisy even when using string compiler flags.
parent 4d391fe6
...@@ -110,6 +110,8 @@ using testing::InitGoogleTest; ...@@ -110,6 +110,8 @@ using testing::InitGoogleTest;
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
void InitGoogleTest(int*, char**);
void InitGoogleTest(int*, char**) {} void InitGoogleTest(int*, char**) {}
// The following is some bare-bones testing infrastructure // The following is some bare-bones testing infrastructure
......
...@@ -301,7 +301,7 @@ static GLogColor SeverityToColor(LogSeverity severity) { ...@@ -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) { ...@@ -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,6 +1677,7 @@ void LogToStderr() { ...@@ -1677,6 +1677,7 @@ void LogToStderr() {
namespace base { namespace base {
namespace internal { namespace internal {
bool GetExitOnDFatal();
bool GetExitOnDFatal() { bool GetExitOnDFatal() {
MutexLock l(&log_mutex); MutexLock l(&log_mutex);
return exit_on_dfatal; return exit_on_dfatal;
...@@ -1692,6 +1693,7 @@ bool GetExitOnDFatal() { ...@@ -1692,6 +1693,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);
void SetExitOnDFatal(bool value) { void SetExitOnDFatal(bool value) {
MutexLock l(&log_mutex); MutexLock l(&log_mutex);
exit_on_dfatal = value; exit_on_dfatal = value;
......
...@@ -1067,10 +1067,10 @@ TEST(Strerror, logging) { ...@@ -1067,10 +1067,10 @@ TEST(Strerror, logging) {
// Simple routines to look at the sizes of generated code for LOG(FATAL) and // Simple routines to look at the sizes of generated code for LOG(FATAL) and
// CHECK(..) via objdump // CHECK(..) via objdump
void MyFatal() { static void MyFatal() {
LOG(FATAL) << "Failed"; LOG(FATAL) << "Failed";
} }
void MyCheck(bool a, bool b) { static void MyCheck(bool a, bool b) {
CHECK_EQ(a, b); CHECK_EQ(a, b);
} }
......
...@@ -48,7 +48,7 @@ using namespace GFLAGS_NAMESPACE; ...@@ -48,7 +48,7 @@ using namespace GFLAGS_NAMESPACE;
using namespace GOOGLE_NAMESPACE; using namespace GOOGLE_NAMESPACE;
void* DieInThread(void*) { static void* DieInThread(void*) {
// We assume pthread_t is an integral number or a pointer, rather // We assume pthread_t is an integral number or a pointer, rather
// than a complex struct. In some environments, pthread_self() // than a complex struct. In some environments, pthread_self()
// returns an uint64 but in some other environments pthread_self() // returns an uint64 but in some other environments pthread_self()
...@@ -62,7 +62,7 @@ void* DieInThread(void*) { ...@@ -62,7 +62,7 @@ void* DieInThread(void*) {
return NULL; return NULL;
} }
void WriteToStdout(const char* data, int size) { static void WriteToStdout(const char* data, int size) {
if (write(STDOUT_FILENO, data, size) < 0) { if (write(STDOUT_FILENO, data, size) < 0) {
// Ignore errors. // Ignore errors.
} }
......
...@@ -103,7 +103,7 @@ AddressRange expected_range[BACKTRACE_STEPS]; ...@@ -103,7 +103,7 @@ AddressRange expected_range[BACKTRACE_STEPS];
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range) static void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range)
{ {
CHECK_GE(ret_addr, range.start); CHECK_GE(ret_addr, range.start);
CHECK_LE(ret_addr, range.end); CHECK_LE(ret_addr, range.end);
...@@ -112,7 +112,7 @@ void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range) ...@@ -112,7 +112,7 @@ void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range)
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
void ATTRIBUTE_NOINLINE CheckStackTrace(int); void ATTRIBUTE_NOINLINE CheckStackTrace(int);
void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) { static void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
const int STACK_LEN = 10; const int STACK_LEN = 10;
void *stack[STACK_LEN]; void *stack[STACK_LEN];
int size; int size;
...@@ -148,7 +148,7 @@ void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) { ...@@ -148,7 +148,7 @@ void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
/* Dummy functions to make the backtrace more interesting. */ /* Dummy functions to make the backtrace more interesting. */
void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) { static void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) {
ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[2]); ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[2]);
INIT_ADDRESS_RANGE(CheckStackTrace4, start, end, &expected_range[1]); INIT_ADDRESS_RANGE(CheckStackTrace4, start, end, &expected_range[1]);
DECLARE_ADDRESS_LABEL(start); DECLARE_ADDRESS_LABEL(start);
...@@ -156,7 +156,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) { ...@@ -156,7 +156,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) {
CheckStackTraceLeaf(); CheckStackTraceLeaf();
DECLARE_ADDRESS_LABEL(end); DECLARE_ADDRESS_LABEL(end);
} }
void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) { static void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) {
ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[3]); ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[3]);
INIT_ADDRESS_RANGE(CheckStackTrace3, start, end, &expected_range[2]); INIT_ADDRESS_RANGE(CheckStackTrace3, start, end, &expected_range[2]);
DECLARE_ADDRESS_LABEL(start); DECLARE_ADDRESS_LABEL(start);
...@@ -164,7 +164,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) { ...@@ -164,7 +164,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) {
CheckStackTrace4(j); CheckStackTrace4(j);
DECLARE_ADDRESS_LABEL(end); DECLARE_ADDRESS_LABEL(end);
} }
void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) { static void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) {
ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[4]); ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[4]);
INIT_ADDRESS_RANGE(CheckStackTrace2, start, end, &expected_range[3]); INIT_ADDRESS_RANGE(CheckStackTrace2, start, end, &expected_range[3]);
DECLARE_ADDRESS_LABEL(start); DECLARE_ADDRESS_LABEL(start);
...@@ -172,7 +172,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) { ...@@ -172,7 +172,7 @@ void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) {
CheckStackTrace3(j); CheckStackTrace3(j);
DECLARE_ADDRESS_LABEL(end); DECLARE_ADDRESS_LABEL(end);
} }
void ATTRIBUTE_NOINLINE CheckStackTrace1(int i) { static void ATTRIBUTE_NOINLINE CheckStackTrace1(int i) {
ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[5]); ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[5]);
INIT_ADDRESS_RANGE(CheckStackTrace1, start, end, &expected_range[4]); INIT_ADDRESS_RANGE(CheckStackTrace1, start, end, &expected_range[4]);
DECLARE_ADDRESS_LABEL(start); DECLARE_ADDRESS_LABEL(start);
......
...@@ -71,7 +71,7 @@ struct user_hash { ...@@ -71,7 +71,7 @@ struct user_hash {
size_t operator()(int x) const { return x; } size_t operator()(int x) const { return x; }
}; };
void TestSTLLogging() { static void TestSTLLogging() {
{ {
// Test a sequence. // Test a sequence.
vector<int> v; vector<int> v;
......
...@@ -634,7 +634,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, ...@@ -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) { ...@@ -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) { ...@@ -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);
......
...@@ -82,6 +82,7 @@ static const char *TrySymbolize(void *pc) { ...@@ -82,6 +82,7 @@ static const char *TrySymbolize(void *pc) {
// Make them C linkage to avoid mangled names. // Make them C linkage to avoid mangled names.
extern "C" { extern "C" {
void nonstatic_func();
void nonstatic_func() { void nonstatic_func() {
volatile int a = 0; volatile int a = 0;
++a; ++a;
...@@ -300,6 +301,7 @@ inline void* always_inline inline_func() { ...@@ -300,6 +301,7 @@ inline void* always_inline inline_func() {
return pc; return pc;
} }
void* ATTRIBUTE_NOINLINE non_inline_func();
void* ATTRIBUTE_NOINLINE non_inline_func() { void* ATTRIBUTE_NOINLINE non_inline_func() {
register void *pc = NULL; register void *pc = NULL;
#ifdef TEST_X86_32_AND_64 #ifdef TEST_X86_32_AND_64
...@@ -308,7 +310,7 @@ void* ATTRIBUTE_NOINLINE non_inline_func() { ...@@ -308,7 +310,7 @@ void* ATTRIBUTE_NOINLINE non_inline_func() {
return pc; return pc;
} }
void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() { static void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
#if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE) #if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE)
void *pc = non_inline_func(); void *pc = non_inline_func();
const char *symbol = TrySymbolize(pc); const char *symbol = TrySymbolize(pc);
...@@ -318,7 +320,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() { ...@@ -318,7 +320,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
#endif #endif
} }
void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() { static void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
#if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE) #if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE)
void *pc = inline_func(); // Must be inlined. void *pc = inline_func(); // Must be inlined.
const char *symbol = TrySymbolize(pc); const char *symbol = TrySymbolize(pc);
...@@ -330,7 +332,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() { ...@@ -330,7 +332,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
} }
// Test with a return address. // Test with a return address.
void ATTRIBUTE_NOINLINE TestWithReturnAddress() { static void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
#if defined(HAVE_ATTRIBUTE_NOINLINE) #if defined(HAVE_ATTRIBUTE_NOINLINE)
void *return_address = __builtin_return_address(0); void *return_address = __builtin_return_address(0);
const char *symbol = TrySymbolize(return_address); const char *symbol = TrySymbolize(return_address);
......
...@@ -84,7 +84,7 @@ static void DebugWriteToStderr(const char* data, void *) { ...@@ -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_ ...@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment