[U-Boot] [PATCH 1/4] mkenvimage: Fix some typos

Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com --- tools/mkenvimage.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 9c32f4a..b7b0e0f 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -116,7 +116,7 @@ int main(int argc, char **argv) /* Check datasize and allocate the data */ if (datasize == 0) { fprintf(stderr, - "Please specify the size of the envrionnment " + "Please specify the size of the environment " "partition.\n"); usage(argv[0]); return EXIT_FAILURE; @@ -182,12 +182,12 @@ int main(int argc, char **argv) ret = close(txt_fd); } /* - * The right test to do is "=>" (not ">") because of the additionnal + * The right test to do is "=>" (not ">") because of the additional * ending \0. See below. */ if (filesize >= envsize) { fprintf(stderr, "The input file is larger than the " - "envrionnment partition size\n"); + "environment partition size\n"); return EXIT_FAILURE; }
@@ -196,7 +196,7 @@ int main(int argc, char **argv) if (filebuf[fp] == '\n') { if (fp == 0) { /* - * Newline at the beggining of the file ? + * Newline at the beginning of the file ? * Ignore it. */ continue;

Since the original implementation indicates explicit error handling we turn off getopt()'s internal error messaging to avoid duplicate error messages. Additionally we add ':' (missing option argument) error handling.
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com --- tools/mkenvimage.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index b7b0e0f..22d1b88 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -80,8 +80,11 @@ int main(int argc, char **argv)
int fp, ep;
+ /* Turn off getopt()'s internal error message */ + opterr = 0; + /* Parse the cmdline */ - while ((option = getopt(argc, argv, "s:o:rbp:h")) != -1) { + while ((option = getopt(argc, argv, ":s:o:rbp:h")) != -1) { switch (option) { case 's': datasize = strtol(optarg, NULL, 0); @@ -106,8 +109,13 @@ int main(int argc, char **argv) case 'h': usage(argv[0]); return EXIT_SUCCESS; + case ':': + fprintf(stderr, "Missing argument for option -%c\n", + optopt); + usage(argv[0]); + return EXIT_FAILURE; default: - fprintf(stderr, "Wrong option -%c\n", option); + fprintf(stderr, "Wrong option -%c\n", optopt); usage(argv[0]); return EXIT_FAILURE; }

Dear Horst Kronstorfer,
In message 1323082526-2125-2-git-send-email-hkronsto@frequentis.com you wrote:
Since the original implementation indicates explicit error handling we turn off getopt()'s internal error messaging to avoid duplicate error messages. Additionally we add ':' (missing option argument) error handling.
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com
tools/mkenvimage.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
Applied to "next" branch, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Horst Kronstorfer hkronsto@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; }

Dear Horst Kronstorfer,
In message 1323082526-2125-3-git-send-email-hkronsto@frequentis.com you wrote:
Signed-off-by: Horst Kronstorfer hkronsto@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

Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com --- Changes for v2: - Use the GNU version of basename(). - Rebased against branch 'next.'
tools/mkenvimage.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 753d9e6..6a6a392 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -25,6 +25,9 @@ * MA 02111-1307 USA */
+/* We want the GNU version of basename() */ +#define _GNU_SOURCE + #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -81,6 +84,9 @@ int main(int argc, char **argv) struct stat txt_file_stat;
int fp, ep; + const char *prg; + + prg = basename(argv[0]);
/* Turn off getopt()'s internal error message */ opterr = 0; @@ -109,7 +115,7 @@ int main(int argc, char **argv) padbyte = strtol(optarg, NULL, 0); break; case 'h': - usage(argv[0]); + usage(prg); return EXIT_SUCCESS; case 'V': printf("%s version %s\n", prg, PLAIN_VERSION); @@ -117,11 +123,11 @@ 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); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; } } @@ -131,7 +137,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; }

Dear Horst Kronstorfer,
In message 1324469157-18032-1-git-send-email-hkronsto@frequentis.com you wrote:
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com
Changes for v2:
- Use the GNU version of basename().
- Rebased against branch 'next.'
tools/mkenvimage.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
This does not apply cleanly against current master:
Applying: Print program basename instead of whole path in usage() Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging tools/mkenvimage.c CONFLICT (content): Merge conflict in tools/mkenvimage.c Failed to merge in the changes. Patch failed at 0001 Print program basename instead of whole path in usage()
Best regards,
Wolfgang Denk

Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com --- Changes for v2: - Use the GNU version of basename(). - Rebase against branch 'next.' Changes for v3: - Rebase against branch 'master.'
tools/mkenvimage.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 9c32f4a..3bb471d 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -25,6 +25,9 @@ * MA 02111-1307 USA */
+/* We want the GNU version of basename() */ +#define _GNU_SOURCE + #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -79,6 +82,9 @@ int main(int argc, char **argv) struct stat txt_file_stat;
int fp, ep; + const char *prg; + + prg = basename(argv[0]);
/* Parse the cmdline */ while ((option = getopt(argc, argv, "s:o:rbp:h")) != -1) { @@ -104,11 +110,11 @@ int main(int argc, char **argv) padbyte = strtol(optarg, NULL, 0); break; case 'h': - usage(argv[0]); + usage(prg); return EXIT_SUCCESS; default: fprintf(stderr, "Wrong option -%c\n", option); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; } } @@ -118,7 +124,7 @@ int main(int argc, char **argv) fprintf(stderr, "Please specify the size of the envrionnment " "partition.\n"); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; }

Dear Horst Kronstorfer,
In message 1324499979-4978-1-git-send-email-hkronsto@frequentis.com you wrote:
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com
Changes for v2:
- Use the GNU version of basename().
- Rebase against branch 'next.'
Changes for v3:
- Rebase against branch 'master.'
tools/mkenvimage.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com --- tools/mkenvimage.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 3e7f967..046661d 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -36,6 +36,7 @@ #include <sys/stat.h>
#include <u-boot/crc.h> +#include <version.h>
#define CRC_SIZE sizeof(uint32_t)
@@ -56,6 +57,7 @@ static void usage(const char *exec_name) "\t-b : the target is big endian (default is little endian)\n" "\t-p <byte> : fill the image with <byte> bytes instead of " "0xff bytes\n" + "\t-V : print version information and exit\n" "\n" "If the input file is "-", data is read from standard input\n", exec_name); @@ -89,7 +91,7 @@ int main(int argc, char **argv) opterr = 0;
/* Parse the cmdline */ - while ((option = getopt(argc, argv, ":s:o:rbp:h")) != -1) { + while ((option = getopt(argc, argv, ":s:o:rbp:hV")) != -1) { switch (option) { case 's': datasize = strtol(optarg, NULL, 0); @@ -114,6 +116,9 @@ int main(int argc, char **argv) case 'h': usage(prg); return EXIT_SUCCESS; + case 'V': + printf("%s version %s\n", prg, PLAIN_VERSION); + return EXIT_SUCCESS; case ':': fprintf(stderr, "Missing argument for option -%c\n", optopt);

Dear Horst Kronstorfer,
In message 1323082526-2125-4-git-send-email-hkronsto@frequentis.com you wrote:
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com
tools/mkenvimage.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
Applied to "next" branch, thanks.
Best regards,
Wolfgang Denk

Dear Horst Kronstorfer,
In message 1323082526-2125-1-git-send-email-hkronsto@frequentis.com you wrote:
Signed-off-by: Horst Kronstorfer hkronsto@frequentis.com
tools/mkenvimage.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
Applied to "next" branch, thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Horst Kronstorfer
-
Wolfgang Denk