[U-Boot] [PATCH 2/2] tools/kwbimage.c: fix build on darwin
andreas.devel at googlemail.com
andreas.devel at googlemail.com
Fri Oct 24 23:39:11 CEST 2014
From: Andreas Bießmann <andreas.devel at googlemail.com>
kwbimage uses get_current_dir_name(3) which is a gnu extension and not
available on darwin host. Fix this by converting to portable getcwd(3)
function.
This patch fixes the following error:
---8<---
HOSTCC tools/kwbimage.o
tools/kwbimage.c:399:16: warning: implicit declaration of function 'get_current_dir_name' is invalid in C99 [-Wimplicit-function-declaration]
char *cwd = get_current_dir_name();
^
tools/kwbimage.c:399:10: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
char *cwd = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
...
Undefined symbols for architecture x86_64:
"_get_current_dir_name", referenced from:
_image_headersz_v1 in kwbimage.o
ld: symbol(s) not found for architecture x86_64
--->8---
Signed-off-by: Andreas Bießmann <andreas.devel at googlemail.com>
Cc: Stefan Roese <sr at denx.de>
---
tools/kwbimage.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index ca4fc78..8fd70ef 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -12,6 +12,7 @@
*/
#include "imagetool.h"
+#include <limits.h>
#include <image.h>
#include <stdint.h>
#include "kwbimage.h"
@@ -396,13 +397,14 @@ static size_t image_headersz_v1(struct image_tool_params *params,
ret = stat(binarye->binary.file, &s);
if (ret < 0) {
- char *cwd = get_current_dir_name();
+ char cwd[PATH_MAX];
+ memset(cwd, 0, sizeof(cwd));
+ getcwd(cwd, sizeof(cwd));
fprintf(stderr,
"Didn't find the file '%s' in '%s' which is mandatory to generate the image\n"
"This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n"
"image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
binarye->binary.file, cwd);
- free(cwd);
return 0;
}
--
1.9.3 (Apple Git-50)
More information about the U-Boot
mailing list