Re: [U-Boot] [PATCH 3/4] mkenvimage: Print program basename instead of whole path in usage()
Dear KRONSTORFER Horst, In message 024fe3275ef7814d9b07390f28c0832c63a24...@vie196nt.frequentis.frq you wrote: + /* Parse program basename */ + prg = strrchr(argv[0], '/'); + prg = (prg) ? prg + 1 : argv[0]; Any reason for not using basename() here? i'm just used to not using basename() ... do you want an updated patch? Yes, please. Using available standard functions is always better than reinventing the wheel. 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: w...@denx.de Unix is supported by IBM, like a hanging man is supported by rope. - Don Libes Sandy Ressler: _Life With Unix_ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/4] mkenvimage: Print program basename instead of whole path in usage()
Dear Horst Kronstorfer, In message 1323082526-2125-3-git-send-email-hkron...@frequentis.com you wrote: Signed-off-by: Horst Kronstorfer hkron...@frequentis.com --- tools/mkenvimage.c | 13 + 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 22d1b88..3e7f967 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -79,6 +79,11 @@ int main(int argc, char **argv) struct stat txt_file_stat; int fp, ep; + const char *prg; + + /* Parse program basename */ + prg = strrchr(argv[0], '/'); + prg = (prg) ? prg + 1 : argv[0]; Any reason for not using basename() here? 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: w...@denx.de The manager will be continually amazed that policies he took for com- mon knowledge are totally unknown by some member of his team. Since his fundamental job is to keep everybody going in the same direction, his chief daily task will be communication, not decision-making. - Fred Brooks, The Mythical Man Month ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/4] mkenvimage: Print program basename instead of whole path in usage()
Signed-off-by: Horst Kronstorfer hkron...@frequentis.com --- tools/mkenvimage.c | 13 + 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 22d1b88..3e7f967 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -79,6 +79,11 @@ int main(int argc, char **argv) struct stat txt_file_stat; int fp, ep; + const char *prg; + + /* Parse program basename */ + prg = strrchr(argv[0], '/'); + prg = (prg) ? prg + 1 : argv[0]; /* Turn off getopt()'s internal error message */ opterr = 0; @@ -107,16 +112,16 @@ int main(int argc, char **argv) padbyte = strtol(optarg, NULL, 0); break; case 'h': - usage(argv[0]); + usage(prg); return EXIT_SUCCESS; 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); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; } } @@ -126,7 +131,7 @@ int main(int argc, char **argv) fprintf(stderr, Please specify the size of the environment partition.\n); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot