Skip to content

Commit

Permalink
Merge pull request #302 from Nazg-Gul/missing-prototype
Browse files Browse the repository at this point in the history
Resolve missing prototype warning
  • Loading branch information
sergiud authored Mar 21, 2018
2 parents 11afec2 + f94a49c commit 2f493d2
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/googletest.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ using testing::InitGoogleTest;

_START_GOOGLE_NAMESPACE_

void InitGoogleTest(int*, char**);

void InitGoogleTest(int*, char**) {}

// The following is some bare-bones testing infrastructure
Expand Down
6 changes: 4 additions & 2 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
#ifdef OS_WINDOWS

// Returns the character attribute for the given color.
WORD GetColorAttribute(GLogColor color) {
static WORD GetColorAttribute(GLogColor color) {
switch (color) {
case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN;
Expand All @@ -311,7 +311,7 @@ WORD GetColorAttribute(GLogColor color) {
#else

// Returns the ANSI color code for the given color.
const char* GetAnsiColorCode(GLogColor color) {
static const char* GetAnsiColorCode(GLogColor color) {
switch (color) {
case COLOR_RED: return "1";
case COLOR_GREEN: return "2";
Expand Down Expand Up @@ -1710,6 +1710,7 @@ void LogToStderr() {
namespace base {
namespace internal {

bool GetExitOnDFatal();
bool GetExitOnDFatal() {
MutexLock l(&log_mutex);
return exit_on_dfatal;
Expand All @@ -1725,6 +1726,7 @@ bool GetExitOnDFatal() {
// and the stack trace is not recorded. The LOG(FATAL) *will* still
// exit the program. Since this function is used only in testing,
// these differences are acceptable.
void SetExitOnDFatal(bool value);
void SetExitOnDFatal(bool value) {
MutexLock l(&log_mutex);
exit_on_dfatal = value;
Expand Down
4 changes: 2 additions & 2 deletions src/logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1075,10 +1075,10 @@ TEST(Strerror, logging) {

// Simple routines to look at the sizes of generated code for LOG(FATAL) and
// CHECK(..) via objdump
void MyFatal() {
static void MyFatal() {
LOG(FATAL) << "Failed";
}
void MyCheck(bool a, bool b) {
static void MyCheck(bool a, bool b) {
CHECK_EQ(a, b);
}

Expand Down
4 changes: 2 additions & 2 deletions src/signalhandler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using namespace GFLAGS_NAMESPACE;

using namespace GOOGLE_NAMESPACE;

void* DieInThread(void*) {
static void* DieInThread(void*) {
// We assume pthread_t is an integral number or a pointer, rather
// than a complex struct. In some environments, pthread_self()
// returns an uint64 but in some other environments pthread_self()
Expand All @@ -64,7 +64,7 @@ void* DieInThread(void*) {
return NULL;
}

void WriteToStdout(const char* data, int size) {
static void WriteToStdout(const char* data, int size) {
if (write(STDOUT_FILENO, data, size) < 0) {
// Ignore errors.
}
Expand Down
12 changes: 6 additions & 6 deletions src/stacktrace_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_LE(ret_addr, range.end);
Expand All @@ -112,7 +112,7 @@ void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range)
//-----------------------------------------------------------------------//

void ATTRIBUTE_NOINLINE CheckStackTrace(int);
void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
static void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
const int STACK_LEN = 10;
void *stack[STACK_LEN];
int size;
Expand Down Expand Up @@ -148,31 +148,31 @@ void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
//-----------------------------------------------------------------------//

/* 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]);
INIT_ADDRESS_RANGE(CheckStackTrace4, start, end, &expected_range[1]);
DECLARE_ADDRESS_LABEL(start);
for (int j = i; j >= 0; j--)
CheckStackTraceLeaf();
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]);
INIT_ADDRESS_RANGE(CheckStackTrace3, start, end, &expected_range[2]);
DECLARE_ADDRESS_LABEL(start);
for (int j = i; j >= 0; j--)
CheckStackTrace4(j);
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]);
INIT_ADDRESS_RANGE(CheckStackTrace2, start, end, &expected_range[3]);
DECLARE_ADDRESS_LABEL(start);
for (int j = i; j >= 0; j--)
CheckStackTrace3(j);
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]);
INIT_ADDRESS_RANGE(CheckStackTrace1, start, end, &expected_range[4]);
DECLARE_ADDRESS_LABEL(start);
Expand Down
2 changes: 1 addition & 1 deletion src/stl_logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct user_hash {
size_t operator()(int x) const { return x; }
};

void TestSTLLogging() {
static void TestSTLLogging() {
{
// Test a sequence.
vector<int> v;
Expand Down
6 changes: 3 additions & 3 deletions src/symbolize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
// bytes. Output will be truncated as needed, and a NUL character is always
// appended.
// 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.
size_t n = 1;
if (n > sz)
Expand Down Expand Up @@ -724,7 +724,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
// 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);
SAFE_ASSERT(dest_string_length < dest_size);
dest += dest_string_length;
Expand All @@ -737,7 +737,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|.
// Never writes past the buffer size |dest_size| and guarantees that |dest| is
// 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.
char buf[17] = {'\0'};
SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size);
Expand Down
8 changes: 5 additions & 3 deletions src/symbolize_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static const char *TrySymbolize(void *pc) {

// Make them C linkage to avoid mangled names.
extern "C" {
void nonstatic_func();
void nonstatic_func() {
volatile int a = 0;
++a;
Expand Down Expand Up @@ -317,6 +318,7 @@ inline void* always_inline inline_func() {
return pc;
}

void* ATTRIBUTE_NOINLINE non_inline_func();
void* ATTRIBUTE_NOINLINE non_inline_func() {
register void *pc = NULL;
#ifdef TEST_X86_32_AND_64
Expand All @@ -325,7 +327,7 @@ void* ATTRIBUTE_NOINLINE non_inline_func() {
return pc;
}

void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
static void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
#if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE)
void *pc = non_inline_func();
const char *symbol = TrySymbolize(pc);
Expand All @@ -335,7 +337,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
#endif
}

void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
static void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
#if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE)
void *pc = inline_func(); // Must be inlined.
const char *symbol = TrySymbolize(pc);
Expand All @@ -347,7 +349,7 @@ void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
}

// Test with a return address.
void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
static void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
#if defined(HAVE_ATTRIBUTE_NOINLINE)
void *return_address = __builtin_return_address(0);
const char *symbol = TrySymbolize(return_address);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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);
}

Expand Down
6 changes: 6 additions & 0 deletions src/vlog_is_on.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ _START_GOOGLE_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
// of arguments and does not allocate any memory,
// but we only support "*" and "?" wildcards, not the "[...]" patterns.
Expand Down

0 comments on commit 2f493d2

Please sign in to comment.