From dabdb72ca27864153e6ea6a83f532693020429e6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 31 May 2011 22:50:56 +0200 Subject: [PATCH] example: Fix build warnings of allocate_module. --- src/example/allocate_module.c | 10 +++++++--- src/example/allocate_module_test.c | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/example/allocate_module.c b/src/example/allocate_module.c index 634932b..c6df8c6 100644 --- a/src/example/allocate_module.c +++ b/src/example/allocate_module.c @@ -32,18 +32,22 @@ extern void _test_free(void* const ptr, const char* file, const int line); #define free(ptr) _test_free(ptr, __FILE__, __LINE__) #endif // UNIT_TESTING -void leak_memory() { +void leak_memory(void); +void buffer_overflow(void); +void buffer_underflow(void); + +void leak_memory(void) { int * const temporary = (int*)malloc(sizeof(int)); *temporary = 0; } -void buffer_overflow() { +void buffer_overflow(void) { char * const memory = (char*)malloc(sizeof(int)); memory[sizeof(int)] = '!'; free(memory); } -void buffer_underflow() { +void buffer_underflow(void) { char * const memory = (char*)malloc(sizeof(int)); memory[-1] = '!'; free(memory); diff --git a/src/example/allocate_module_test.c b/src/example/allocate_module_test.c index 3e9c022..b4519b5 100644 --- a/src/example/allocate_module_test.c +++ b/src/example/allocate_module_test.c @@ -23,17 +23,17 @@ extern void buffer_overflow(); extern void buffer_underflow(); // Test case that fails as leak_memory() leaks a dynamically allocated block. -void leak_memory_test(void **state) { +static void leak_memory_test(void **state) { leak_memory(); } // Test case that fails as buffer_overflow() corrupts an allocated block. -void buffer_overflow_test(void **state) { +static void buffer_overflow_test(void **state) { buffer_overflow(); } // Test case that fails as buffer_underflow() corrupts an allocated block. -void buffer_underflow_test(void **state) { +static void buffer_underflow_test(void **state) { buffer_underflow(); } -- 2.7.4