[OpenBIOS] [PATCH 6/6] libc: Fix build on recent gcc
Aurelien Jarno
aurelien at aurel32.net
Sun Nov 6 23:41:40 CET 2016
On 2016-08-02 15:35, Benjamin Herrenschmidt wrote:
> 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;
> }
Sorry to react so late, but wouldn't be better to build openbios with
-ffreestanding instead? That way GCC doesn't try to infer things from
its knowledge of the GNU libc? After all openbios uses its own libc.
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien at aurel32.net http://www.aurel32.net
More information about the OpenBIOS
mailing list