Skip to content
Snippets Groups Projects
Commit e5f1a586 authored by Andreas Bießmann's avatar Andreas Bießmann Committed by Anatolij Gustschin
Browse files

tools/kwbimage.c: fix build on darwin


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: default avatarAndreas Bießmann <andreas.devel@googlemail.com>
Cc: Stefan Roese <sr@denx.de>
Acked-by: default avatarStefan Roese <sr@denx.de>
[agust: fixed getcwd() return warning]
Signed-off-by: default avatarAnatolij Gustschin <agust@denx.de>
parent 571bdf16
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
#include "imagetool.h" #include "imagetool.h"
#include <limits.h>
#include <image.h> #include <image.h>
#include <stdint.h> #include <stdint.h>
#include "kwbimage.h" #include "kwbimage.h"
...@@ -396,13 +397,20 @@ static size_t image_headersz_v1(struct image_tool_params *params, ...@@ -396,13 +397,20 @@ static size_t image_headersz_v1(struct image_tool_params *params,
ret = stat(binarye->binary.file, &s); ret = stat(binarye->binary.file, &s);
if (ret < 0) { if (ret < 0) {
char *cwd = get_current_dir_name(); char cwd[PATH_MAX];
char *dir = cwd;
memset(cwd, 0, sizeof(cwd));
if (!getcwd(cwd, sizeof(cwd))) {
dir = "current working directory";
perror("getcwd() failed");
}
fprintf(stderr, fprintf(stderr,
"Didn't find the file '%s' in '%s' which is mandatory to generate the image\n" "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" "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", "image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
binarye->binary.file, cwd); binarye->binary.file, dir);
free(cwd);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment