* [U-Boot] [PATCH] Avoid using GNU basename
@ 2012-02-28 15:36 Keith Mok
2012-02-29 18:51 ` Mike Frysinger
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Keith Mok @ 2012-02-28 15:36 UTC (permalink / raw)
To: u-boot
There is no GNU basename support in MacOS.
Use generic POSIX basename defined in libgen.h instead.
Signed-off-by: Keith Mok <ek9852@gmail.com>
---
tools/mkenvimage.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index f781731..8b49723 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -25,9 +25,6 @@
* MA 02111-1307 USA
*/
-/* We want the GNU version of basename() */
-#define _GNU_SOURCE
-
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -35,6 +32,7 @@
#include <string.h>
#include <unistd.h>
#include <compiler.h>
+#include <libgen.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -85,8 +83,10 @@ int main(int argc, char **argv)
int fp, ep;
const char *prg;
+ char *prog_pathname;
- prg = basename(argv[0]);
+ prog_pathname = strdup(argv[0]);
+ prg = basename(prog_pathname);
/* Turn off getopt()'s internal error message */
opterr = 0;
--
1.7.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] Avoid using GNU basename
2012-02-28 15:36 [U-Boot] [PATCH] Avoid using GNU basename Keith Mok
@ 2012-02-29 18:51 ` Mike Frysinger
2012-03-02 7:16 ` Wolfgang Denk
2012-03-02 7:19 ` [U-Boot] [PATCH] mkenvimage: fix usage message Wolfgang Denk
2 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-02-29 18:51 UTC (permalink / raw)
To: u-boot
On Tuesday 28 February 2012 10:36:22 Keith Mok wrote:
> There is no GNU basename support in MacOS.
> Use generic POSIX basename defined in libgen.h instead.
alternative: define a non-braindead version in compiler.h:
static const char *_basename(const char *filename)
{
const char *p = strrchr(filename, '/');
return p ? p + 1 : filename;
}
/* Avoid issues with clobbering C library def */
#undef basename
#define basename(x) _basename(x)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120229/c9d26b8c/attachment.pgp>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] Avoid using GNU basename
2012-02-28 15:36 [U-Boot] [PATCH] Avoid using GNU basename Keith Mok
2012-02-29 18:51 ` Mike Frysinger
@ 2012-03-02 7:16 ` Wolfgang Denk
2012-03-02 14:09 ` Keith Mok
2012-03-02 7:19 ` [U-Boot] [PATCH] mkenvimage: fix usage message Wolfgang Denk
2 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2012-03-02 7:16 UTC (permalink / raw)
To: u-boot
Dear Keith Mok,
In message <CAHjoi4eR+n=qQ8vZAKwwgLiPSFfrBWHRHwYNvfJn4y0F9EqO7g@mail.gmail.com> you wrote:
> There is no GNU basename support in MacOS.
> Use generic POSIX basename defined in libgen.h instead.
...
> int fp, ep;
> const char *prg;
> + char *prog_pathname;
>
> - prg = basename(argv[0]);
> + prog_pathname = strdup(argv[0]);
> + prg = basename(prog_pathname);
free() missing. Actually the strdup should not be needed at all,
as we don't use argv[0] after that - at least we shouldn't. The
remaining "usage(argv[0]);" should be fixed instead.
Besides - I agree with Mike's comment how your MacOS issue should be
fixed.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Drun'? 'm not drun'! You woudn' dare call m' drun' if I was sober!
- Terry Pratchett, _Men at Arms_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] mkenvimage: fix usage message
2012-02-28 15:36 [U-Boot] [PATCH] Avoid using GNU basename Keith Mok
2012-02-29 18:51 ` Mike Frysinger
2012-03-02 7:16 ` Wolfgang Denk
@ 2012-03-02 7:19 ` Wolfgang Denk
2012-03-02 18:39 ` Mike Frysinger
2012-03-26 11:24 ` Anatolij Gustschin
2 siblings, 2 replies; 9+ messages in thread
From: Wolfgang Denk @ 2012-03-02 7:19 UTC (permalink / raw)
To: u-boot
Don;t use argv[0] for usage() because it may or may not be clobbered
by the previous call to basename(). Use "prg" instead as it is done
in the rest of the code.
Signed-off-by: Wolfgang Denk <wd@denx.de>
---
tools/mkenvimage.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index f781731..64f5340 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
case ':':
fprintf(stderr, "Missing argument for option -%c\n",
optopt);
- usage(argv[0]);
+ usage(prg);
return EXIT_FAILURE;
default:
fprintf(stderr, "Wrong option -%c\n", optopt);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] Avoid using GNU basename
2012-03-02 7:16 ` Wolfgang Denk
@ 2012-03-02 14:09 ` Keith Mok
2012-03-02 16:42 ` Wolfgang Denk
0 siblings, 1 reply; 9+ messages in thread
From: Keith Mok @ 2012-03-02 14:09 UTC (permalink / raw)
To: u-boot
Hi Wolfgang,
> Besides - I agree with Mike's comment how your MacOS issue should be
> fixed.
But will Mike's fix break Windows user which cross-compile u-boot ?
The path separator is '\' instead of '/'
Regards,
Keith
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] Avoid using GNU basename
2012-03-02 14:09 ` Keith Mok
@ 2012-03-02 16:42 ` Wolfgang Denk
[not found] ` <CAHjoi4eRTxXJKwg_XsEvtELNQmDzfqHzZiRO=MY-jfVYvDUrgA@mail.gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2012-03-02 16:42 UTC (permalink / raw)
To: u-boot
Dear Keith Mok,
In message <CAHjoi4dV3gP1XqoH5vUy_NJAFouAx3HbTt-bHqfP2nrt-2o39w@mail.gmail.com> you wrote:
>
> > Besides - I agree with Mike's comment how your MacOS issue should be
> > fixed.
> But will Mike's fix break Windows user which cross-compile u-boot ?
> The path separator is '\' instead of '/'
I'm not a windows expert (actually I'm proud of never having worked
with Windows in my whole life), but I think it is only the command
line interface that insists of using '\\' (because DOS used '/' as
option switch).
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Whom the gods would destroy, they first teach BASIC.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] mkenvimage: fix usage message
2012-03-02 7:19 ` [U-Boot] [PATCH] mkenvimage: fix usage message Wolfgang Denk
@ 2012-03-02 18:39 ` Mike Frysinger
2012-03-26 11:24 ` Anatolij Gustschin
1 sibling, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-03-02 18:39 UTC (permalink / raw)
To: u-boot
On Friday 02 March 2012 02:19:40 Wolfgang Denk wrote:
> Don;t use argv[0] for usage() because it may or may not be clobbered
Don't
> by the previous call to basename(). Use "prg" instead as it is done
> in the rest of the code.
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120302/2371121d/attachment.pgp>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] Avoid using GNU basename
[not found] ` <CAHjoi4eRTxXJKwg_XsEvtELNQmDzfqHzZiRO=MY-jfVYvDUrgA@mail.gmail.com>
@ 2012-03-03 16:06 ` Wolfgang Denk
0 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Denk @ 2012-03-03 16:06 UTC (permalink / raw)
To: u-boot
Dear Keith,
please keep the mailing list on Cc:
In message <CAHjoi4eRTxXJKwg_XsEvtELNQmDzfqHzZiRO=MY-jfVYvDUrgA@mail.gmail.com> you wrote:
>
> > I'm not a windows expert (actually I'm proud of never having worked
> > with Windows in my whole life), but I think it is only the command
> > line interface that insists of using '\\' (because DOS used '/' as
> > option switch).
> So should we stick on using libgen provided basename to maximize the
> compatibility of different platforms ?
I don't think so. As the comment in "/usr/include/libgen.h" suggests,
we should use "the weird XPG version of this function" only when
really needed. And we definitely don;t need to do that on GNU/Linux
systems.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Hindsight is an exact science.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] mkenvimage: fix usage message
2012-03-02 7:19 ` [U-Boot] [PATCH] mkenvimage: fix usage message Wolfgang Denk
2012-03-02 18:39 ` Mike Frysinger
@ 2012-03-26 11:24 ` Anatolij Gustschin
1 sibling, 0 replies; 9+ messages in thread
From: Anatolij Gustschin @ 2012-03-26 11:24 UTC (permalink / raw)
To: u-boot
Hello Wolfgang,
On Fri, 2 Mar 2012 08:19:40 +0100
Wolfgang Denk <wd@denx.de> wrote:
> Don;t use argv[0] for usage() because it may or may not be clobbered
> by the previous call to basename(). Use "prg" instead as it is done
> in the rest of the code.
>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> ---
> tools/mkenvimage.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied to u-boot-staging.
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-26 11:24 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 15:36 [U-Boot] [PATCH] Avoid using GNU basename Keith Mok
2012-02-29 18:51 ` Mike Frysinger
2012-03-02 7:16 ` Wolfgang Denk
2012-03-02 14:09 ` Keith Mok
2012-03-02 16:42 ` Wolfgang Denk
[not found] ` <CAHjoi4eRTxXJKwg_XsEvtELNQmDzfqHzZiRO=MY-jfVYvDUrgA@mail.gmail.com>
2012-03-03 16:06 ` Wolfgang Denk
2012-03-02 7:19 ` [U-Boot] [PATCH] mkenvimage: fix usage message Wolfgang Denk
2012-03-02 18:39 ` Mike Frysinger
2012-03-26 11:24 ` Anatolij Gustschin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.