From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatolij Gustschin Date: Fri, 31 Oct 2014 00:27:45 +0100 Subject: [U-Boot] [PATCH 2/2] tools/kwbimage.c: fix build on darwin In-Reply-To: <20141030231103.2934b3e2@crub> References: <1414186751-3061-1-git-send-email-andreas.devel@googlemail.com> <1414186751-3061-3-git-send-email-andreas.devel@googlemail.com> <20141030231103.2934b3e2@crub> Message-ID: <20141031002745.576b34ec@crub> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, 30 Oct 2014 23:11:03 +0100 Anatolij Gustschin wrote: > On Fri, 24 Oct 2014 23:39:11 +0200 > andreas.devel at googlemail.com wrote: > > > From: Andreas Bie?mann > > > > 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 > > Cc: Stefan Roese > > > > --- > > > > tools/kwbimage.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > Applied to u-boot-staging. Thanks! Now I see tools/kwbimage.c:402:4: warning: ignoring return value of ?getcwd?, declared with attribute warn_unused_result [-Wunused-result] So, additionally applied: diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 0a388c8..ec52f9e 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -398,13 +398,19 @@ static size_t image_headersz_v1(struct image_tool_params *params, ret = stat(binarye->binary.file, &s); if (ret < 0) { char cwd[PATH_MAX]; + char *dir = cwd; + memset(cwd, 0, sizeof(cwd)); - getcwd(cwd, sizeof(cwd)); + if (!getcwd(cwd, sizeof(cwd))) { + dir = "current working directory"; + perror("getcwd() failed"); + } + 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, dir); return 0; }