From d2211c83365e5473cede0aa4704294d03270e59c Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 27 May 2019 11:57:42 +0200 Subject: scripts: kwbimage: fix build with non-glibc systems get_current_dir_name is a glibc extension, thus replace it with a call to standard POSIX pathconf/malloc/gecwd. The result slightly differs, because get_current_dir_name consults the $PWD environment variable as as well, but that's ok, as it's just an error message. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- scripts/kwbimage.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c index 2a052a7ff3..6ba4abaa30 100644 --- a/scripts/kwbimage.c +++ b/scripts/kwbimage.c @@ -860,12 +860,16 @@ static void *image_create_v1(struct image_cfg_element *image_cfg, ret = stat(binarye->binary.file, &s); if (ret < 0) { - char *cwd = get_current_dir_name(); + char *buf, *cwd = NULL; + size_t size = (size_t)pathconf(".", _PC_PATH_MAX); + buf = malloc(size); + if (buf) + cwd = getcwd(buf, size); 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); + binarye->binary.file, cwd ? cwd : "current working directory"); free(cwd); return NULL; } -- cgit v1.2.3