[OpenBIOS] [PATCH 6/6] libc: Fix build on recent gcc

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Aug 2 07:35:27 CEST 2016


This fixes this warning (which escalates as an error):

roms/openbios/libc/string.c: In function ‘strdup’:
roms/openbios/libc/string.c:353:4: error: nonnull argument ‘str’ compared to NULL [-Werror=nonnull-compare]
  if( !str )
    ^
cc1: all warnings being treated as errors
rules.mak:122: recipe for target 'target/libc		printf("stdout is %s\n", stdout->name);

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 libc/string.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libc/string.c b/libc/string.c
index 8f62bd7..bde9a61 100644
--- a/libc/string.c
+++ b/libc/string.c
@@ -349,10 +349,7 @@ int memcmp(const void * cs,const void * ct,size_t count)
 char *
 strdup( const char *str )
 {
-	char *p;
-	if( !str )
-		return NULL;
-	p = malloc( strlen(str) + 1 );
+	char *p = malloc( strlen(str) + 1 );
 	strcpy( p, str );
 	return p;
 }
-- 
2.7.4




More information about the OpenBIOS mailing list