[U-Boot] [PATCH] sandbox: fix the return type of os_free() function

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Jan 15 05:06:41 CET 2014


The function os_free() returns nothing.
Its return type should be "void" rather than "void *".

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---

Simon,

This commit fixes a warning:

u-boot/include/os.h: In function ‘os_free’:
arch/sandbox/cpu/os.c:153:1: warning: control reaches end of non-void function [-Wreturn-type]

But, this warning message is not displayed on the current u-boot/master
because commit cbe5cdfcd3 changed arch/sandbox/cpu/Makefile badly.

The build rule in arch/sandbox/cpu/Makefile

  $(obj)os.o: ALL_CFLAGS := $(BASE_CPPFLAGS) \
        $(patsubst %, -idirafter %, $(BASE_INCLUDE_DIRS))

drops many flags including "-Wall".

That's why you did not notice such a mistake,
which the build system should have detected.

This problem can be fixed in my patch
http://patchwork.ozlabs.org/patch/294233/
(It is also a prerequisite for my Kbuild series.)


 arch/sandbox/cpu/os.c | 2 +-
 include/os.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 725b505..2e2fc58 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -143,7 +143,7 @@ void *os_malloc(size_t length)
 	return hdr + 1;
 }
 
-void *os_free(void *ptr)
+void os_free(void *ptr)
 {
 	struct os_mem_hdr *hdr = ptr;
 
diff --git a/include/os.h b/include/os.h
index b65fba4..d6d6e57 100644
--- a/include/os.h
+++ b/include/os.h
@@ -113,7 +113,7 @@ void *os_malloc(size_t length);
  *
  * \param ptr		Pointer to memory block to free
  */
-void *os_free(void *ptr);
+void os_free(void *ptr);
 
 /**
  * Reallocate previously-allocated memory to increase/decrease space
-- 
1.8.3.2



More information about the U-Boot mailing list