diff mbox

[U-Boot] tools/mkenvimage.c: fix basename(3) usage

Message ID 1340863319-63074-1-git-send-email-andreas.devel@googlemail.com
State Accepted
Commit 558cd995d6d3eaa94fb342d142289a1fa2f76ba3
Headers show

Commit Message

Andreas Bießmann June 28, 2012, 6:01 a.m. UTC
Use the POSIX variant of basename due to BSD systems (e.g. OS X) do not provide
GNU version of basename(3). It is save to use the POSIX variant here cause we do
never use argv[0] later on which may be modified by the basename(3) POSIX
variant.
On systems providing GNU variant the GNU variant should be used since string.h
is included before libgen.h. Therefore let the _GNU_SOURCE as is.

This patch fixes following warning (on OS X):
---8<---
mkenvimage.c: In function ‘main’:
mkenvimage.c:105: warning: implicit declaration of function ‘basename’
mkenvimage.c:105: warning: assignment makes pointer from integer without a cast
--->8---

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
cc: Keith Mok <ek9852@gmail.com>
---
This was sent by Keith Mok before. Read
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/126003

 tools/mkenvimage.c | 1 +
 1 Datei geändert, 1 Zeile hinzugefügt(+)

Comments

Wolfgang Denk July 2, 2012, 6:22 p.m. UTC | #1
Dear =?UTF-8?q?Andreas=20Bie=C3=9Fmann?=,

In message <1340863319-63074-1-git-send-email-andreas.devel@googlemail.com> you wrote:
> Use the POSIX variant of basename due to BSD systems (e.g. OS X) do not provide
> GNU version of basename(3). It is save to use the POSIX variant here cause we do
> never use argv[0] later on which may be modified by the basename(3) POSIX
> variant.
> On systems providing GNU variant the GNU variant should be used since string.h
> is included before libgen.h. Therefore let the _GNU_SOURCE as is.
> 
> This patch fixes following warning (on OS X):
> ---8<---
> mkenvimage.c: In function ‘main’:
> mkenvimage.c:105: warning: implicit declaration of function ‘basename’
> mkenvimage.c:105: warning: assignment makes pointer from integer without a cast
> --->8---
> 
> Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
> cc: Keith Mok <ek9852@gmail.com>
> ---
> This was sent by Keith Mok before. Read
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/126003
> 
>  tools/mkenvimage.c | 1 +
>  1 Datei geändert, 1 Zeile hinzugefügt(+)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index bfc4eb6..5521268 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -35,6 +35,7 @@ 
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
+#include <libgen.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>