* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages
@ 2012-01-13 23:27 David Wagner
2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner
` (7 more replies)
0 siblings, 8 replies; 24+ messages in thread
From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw)
To: u-boot
Also, don't split error messages over several lines as per a coding style
exception making them easier to grep.
Signed-off-by: David Wagner <david.wagner@free-electrons.com>
---
tools/mkenvimage.c | 41 +++++++++++++++--------------------------
1 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index f781731..c95f7f5 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -45,12 +45,9 @@
static void usage(const char *exec_name)
{
- fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] "
- "-s <environment partition size> -o <output> <input file>\n"
+ fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>\n"
"\n"
- "This tool takes a key=value input file (same as would a "
- "`printenv' show) and generates the corresponding environment "
- "image, ready to be flashed.\n"
+ "This tool takes a key=value input file (same as would a `printenv' show) and generates the corresponding environment image, ready to be flashed.\n"
"\n"
"\tThe input file is in format:\n"
"\t\tkey1=value1\n"
@@ -58,8 +55,7 @@ static void usage(const char *exec_name)
"\t\t...\n"
"\t-r : the environment has multiple copies in flash\n"
"\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-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",
@@ -100,8 +96,7 @@ int main(int argc, char **argv)
case 'o':
bin_filename = strdup(optarg);
if (!bin_filename) {
- fprintf(stderr, "Can't strdup() the output "
- "filename\n");
+ fprintf(stderr, "Can't strdup() the output filename\n");
return EXIT_FAILURE;
}
break;
@@ -118,7 +113,7 @@ int main(int argc, char **argv)
usage(prg);
return EXIT_SUCCESS;
case 'V':
- printf("%s version %s\n", prg, PLAIN_VERSION);
+ printf("%s version %s\n", argv[0], PLAIN_VERSION);
return EXIT_SUCCESS;
case ':':
fprintf(stderr, "Missing argument for option -%c\n",
@@ -134,22 +129,21 @@ int main(int argc, char **argv)
/* Check datasize and allocate the data */
if (datasize == 0) {
- fprintf(stderr,
- "Please specify the size of the environment "
- "partition.\n");
+ fprintf(stderr, "Please specify the size of the environment partition.\n");
usage(prg);
return EXIT_FAILURE;
}
dataptr = malloc(datasize * sizeof(*dataptr));
if (!dataptr) {
- fprintf(stderr, "Can't alloc dataptr.\n");
+ fprintf(stderr, "Can't alloc %d bytes for dataptr.\n",
+ datasize);
return EXIT_FAILURE;
}
/*
* envptr points to the beginning of the actual environment (after the
- * crc and possible `redundant' bit
+ * crc and possible `redundant' byte
*/
envsize = datasize - (CRC_SIZE + redundant);
envptr = dataptr + CRC_SIZE + redundant;
@@ -185,8 +179,8 @@ int main(int argc, char **argv)
/* ... and check it */
ret = fstat(txt_fd, &txt_file_stat);
if (ret == -1) {
- fprintf(stderr, "Can't stat() on \"%s\": "
- "%s\n", txt_filename, strerror(errno));
+ fprintf(stderr, "Can't stat() on \"%s\": %s\n",
+ txt_filename, strerror(errno));
return EXIT_FAILURE;
}
@@ -200,13 +194,9 @@ int main(int argc, char **argv)
}
ret = close(txt_fd);
}
- /*
- * 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 "
- "environment partition size\n");
+ /* The +1 is for the additionnal ending \0. See below. */
+ if (filesize + 1 > envsize) {
+ fprintf(stderr, "The input file is larger than the environment partition size\n");
return EXIT_FAILURE;
}
@@ -255,8 +245,7 @@ int main(int argc, char **argv)
* check the env size again to make sure we have room for two \0
*/
if (ep >= envsize) {
- fprintf(stderr, "The environment file is too large for "
- "the target environment storage\n");
+ fprintf(stderr, "The environment file is too large for the target environment storage\n");
return EXIT_FAILURE;
}
envptr[ep] = '\0';
--
1.7.5.4
^ permalink raw reply related [flat|nested] 24+ messages in thread* [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:23 ` Mike Frysinger 2012-03-27 8:50 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling David Wagner ` (6 subsequent siblings) 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot compiler.h needs to be included from U-Boot's headers. Also, group U-Boot-specific includes together stdlib.h was missing. Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index c95f7f5..810a89e 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -31,13 +31,14 @@ #include <errno.h> #include <fcntl.h> #include <stdio.h> +#include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> -#include <compiler.h> #include <sys/types.h> #include <sys/stat.h> +#include "compiler.h" #include <u-boot/crc.h> #include <version.h> -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one 2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner @ 2012-01-15 1:23 ` Mike Frysinger 2012-03-27 8:50 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:23 UTC (permalink / raw) To: u-boot 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/20120114/09977e48/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one 2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner 2012-01-15 1:23 ` Mike Frysinger @ 2012-03-27 8:50 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:50 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:35 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > compiler.h needs to be included from U-Boot's headers. > Also, group U-Boot-specific includes together > > stdlib.h was missing. > > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner 2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:24 ` Mike Frysinger 2012-03-27 8:51 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" David Wagner ` (5 subsequent siblings) 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot Verbosly fail if the target environment size or the padding byte are badly formated. Verbosly fail if something bad happens when reading from standard input. Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 810a89e..cc1deec 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -63,6 +63,24 @@ static void usage(const char *exec_name) exec_name); } +long int xstrtol(const char *s) +{ + long int tmp; + + errno = 0; + tmp = strtol(s, NULL, 0); + if (!errno) + return tmp; + + if (errno == ERANGE) + fprintf(stderr, "Bad integer format: %s\n", s); + else + fprintf(stderr, "Error while parsing %s: %s\n", s, + strerror(errno)); + + exit(EXIT_FAILURE); +} + int main(int argc, char **argv) { uint32_t crc, targetendian_crc; @@ -92,7 +110,7 @@ int main(int argc, char **argv) while ((option = getopt(argc, argv, ":s:o:rbp:hV")) != -1) { switch (option) { case 's': - datasize = strtol(optarg, NULL, 0); + datasize = xstrtol(optarg); break; case 'o': bin_filename = strdup(optarg); @@ -108,7 +126,7 @@ int main(int argc, char **argv) bigendian = 1; break; case 'p': - padbyte = strtol(optarg, NULL, 0); + padbyte = xstrtol(optarg); break; case 'h': usage(prg); @@ -166,7 +184,16 @@ int main(int argc, char **argv) do { filebuf = realloc(filebuf, readlen); + if (!filebuf) { + fprintf(stderr, "Can't realloc memory for the input file buffer\n"); + return EXIT_FAILURE; + } readbytes = read(txt_fd, filebuf + filesize, readlen); + if (errno) { + fprintf(stderr, "Error while reading stdin: %s\n", + strerror(errno)); + return EXIT_FAILURE; + } filesize += readbytes; } while (readbytes == readlen); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling 2012-01-13 23:27 ` [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling David Wagner @ 2012-01-15 1:24 ` Mike Frysinger 2012-03-27 8:51 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:24 UTC (permalink / raw) To: u-boot On Friday 13 January 2012 18:27:36 David Wagner wrote: > --- a/tools/mkenvimage.c > +++ b/tools/mkenvimage.c > > +long int xstrtol(const char *s) long term, we'll prob want to add a host set of helper libs like xmalloc and xstrdup and xstrtol so we don't have to copy & paste between tools ... for now: 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/20120114/76c4dc98/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling 2012-01-13 23:27 ` [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling David Wagner 2012-01-15 1:24 ` Mike Frysinger @ 2012-03-27 8:51 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:51 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:36 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Verbosly fail if the target environment size or the padding byte are badly > formated. > > Verbosly fail if something bad happens when reading from standard input. > > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 31 +++++++++++++++++++++++++++++-- > 1 files changed, 29 insertions(+), 2 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner 2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner 2012-01-13 23:27 ` [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file David Wagner ` (4 subsequent siblings) 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index cc1deec..a5676be 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -171,15 +171,9 @@ int main(int argc, char **argv) memset(envptr, padbyte, envsize); /* Open the input file ... */ - if (optind >= argc) { - fprintf(stderr, "Please specify an input filename\n"); - return EXIT_FAILURE; - } - - txt_filename = argv[optind]; - if (strcmp(txt_filename, "-") == 0) { + if (optind >= argc || strcmp(argv[optind], "-") == 0) { int readbytes = 0; - int readlen = sizeof(*envptr) * 2048; + int readlen = sizeof(*envptr) * 4096; txt_fd = STDIN_FILENO; do { @@ -198,6 +192,7 @@ int main(int argc, char **argv) } while (readbytes == readlen); } else { + txt_filename = argv[optind]; txt_fd = open(txt_filename, O_RDONLY); if (txt_fd == -1) { fprintf(stderr, "Can't open \"%s\": %s\n", @@ -287,11 +282,16 @@ int main(int argc, char **argv) memcpy(dataptr, &targetendian_crc, sizeof(uint32_t)); - bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); - if (bin_fd == -1) { - fprintf(stderr, "Can't open output file \"%s\": %s\n", - bin_filename, strerror(errno)); - return EXIT_FAILURE; + if (!bin_filename || strcmp(bin_filename, "-") == 0) { + bin_fd = STDOUT_FILENO; + } else { + bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP); + if (bin_fd == -1) { + fprintf(stderr, "Can't open output file \"%s\": %s\n", + bin_filename, strerror(errno)); + return EXIT_FAILURE; + } } if (write(bin_fd, dataptr, sizeof(*dataptr) * datasize) != -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" 2012-01-13 23:27 ` [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" David Wagner @ 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:25 UTC (permalink / raw) To: u-boot 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/20120114/8178d261/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" 2012-01-13 23:27 ` [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" David Wagner 2012-01-15 1:25 ` Mike Frysinger @ 2012-03-27 8:52 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:52 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:37 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 26 +++++++++++++------------- > 1 files changed, 13 insertions(+), 13 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner ` (2 preceding siblings ...) 2012-01-13 23:27 ` [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file David Wagner ` (3 subsequent siblings) 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot Fall back to read() if it fails. Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index a5676be..8ce1be6 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -37,6 +37,7 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/mman.h> #include "compiler.h" #include <u-boot/crc.h> @@ -208,12 +209,24 @@ int main(int argc, char **argv) } filesize = txt_file_stat.st_size; - /* Read the raw input file and transform it */ - filebuf = malloc(sizeof(*envptr) * filesize); - ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize); - if (ret != sizeof(*envptr) * filesize) { - fprintf(stderr, "Can't read the whole input file\n"); - return EXIT_FAILURE; + + filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ, + MAP_PRIVATE, txt_fd, 0); + if (filebuf == MAP_FAILED) { + fprintf(stderr, "mmap (%ld bytes) failed: %s\n", + sizeof(*envptr) * filesize, + strerror(errno)); + fprintf(stderr, "Falling back to read()\n"); + + filebuf = malloc(sizeof(*envptr) * filesize); + ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize); + if (ret != sizeof(*envptr) * filesize) { + fprintf(stderr, "Can't read the whole input file (%ld bytes): %s\n", + sizeof(*envptr) * filesize, + strerror(errno)); + + return EXIT_FAILURE; + } } ret = close(txt_fd); } -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file 2012-01-13 23:27 ` [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file David Wagner @ 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:25 UTC (permalink / raw) To: u-boot 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/20120114/4468a826/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file 2012-01-13 23:27 ` [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file David Wagner 2012-01-15 1:25 ` Mike Frysinger @ 2012-03-27 8:52 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:52 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:38 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Fall back to read() if it fails. > > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 25 +++++++++++++++++++------ > 1 files changed, 19 insertions(+), 6 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner ` (3 preceding siblings ...) 2012-01-13 23:27 ` [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable David Wagner ` (2 subsequent siblings) 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot Remove this feature since it seems impossible to reliably detect them. Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 8ce1be6..ddd4515 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -258,14 +258,6 @@ int main(int argc, char **argv) /* End of a variable */ envptr[ep++] = '\0'; } - } else if (filebuf[fp] == '#') { - if (fp != 0 && filebuf[fp-1] == '\n') { - /* This line is a comment, let's skip it */ - while (fp < txt_file_stat.st_size && fp++ && - filebuf[fp] != '\n'); - } else { - envptr[ep++] = filebuf[fp]; - } } else { envptr[ep++] = filebuf[fp]; } -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file 2012-01-13 23:27 ` [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file David Wagner @ 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:26 UTC (permalink / raw) To: u-boot On Friday 13 January 2012 18:27:39 David Wagner wrote: > Remove this feature since it seems impossible to reliably detect them. would be nice to have these, but i can see how it'd be hard to detect multiline vars and comments ... 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/20120114/346d6c67/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file 2012-01-13 23:27 ` [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file David Wagner 2012-01-15 1:26 ` Mike Frysinger @ 2012-03-27 8:53 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:53 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:39 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Remove this feature since it seems impossible to reliably detect them. > > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 8 -------- > 1 files changed, 0 insertions(+), 8 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner ` (4 preceding siblings ...) 2012-01-13 23:27 ` [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file David Wagner @ 2012-01-13 23:27 ` David Wagner 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 2012-01-15 1:22 ` [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages Mike Frysinger 2012-03-27 8:48 ` Anatolij Gustschin 7 siblings, 2 replies; 24+ messages in thread From: David Wagner @ 2012-01-13 23:27 UTC (permalink / raw) To: u-boot Signed-off-by: David Wagner <david.wagner@free-electrons.com> --- tools/mkenvimage.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index ddd4515..e148f89 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -285,7 +285,9 @@ int main(int argc, char **argv) crc = crc32(0, envptr, envsize); targetendian_crc = bigendian ? cpu_to_be32(crc) : cpu_to_le32(crc); - memcpy(dataptr, &targetendian_crc, sizeof(uint32_t)); + memcpy(dataptr, &targetendian_crc, sizeof(targetendian_crc)); + if (redundant) + dataptr[sizeof(targetendian_crc)] = 1; if (!bin_filename || strcmp(bin_filename, "-") == 0) { bin_fd = STDOUT_FILENO; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable 2012-01-13 23:27 ` [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable David Wagner @ 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:26 UTC (permalink / raw) To: u-boot 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/20120114/65dc23bc/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable 2012-01-13 23:27 ` [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable David Wagner 2012-01-15 1:26 ` Mike Frysinger @ 2012-03-27 8:53 ` Anatolij Gustschin 1 sibling, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:53 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:40 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) Applied to u-boot-staging/agust at denx.de, thanks. Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner ` (5 preceding siblings ...) 2012-01-13 23:27 ` [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable David Wagner @ 2012-01-15 1:22 ` Mike Frysinger 2012-02-26 0:19 ` David Wagner 2012-03-27 8:48 ` Anatolij Gustschin 7 siblings, 1 reply; 24+ messages in thread From: Mike Frysinger @ 2012-01-15 1:22 UTC (permalink / raw) To: u-boot 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/20120114/013f9f45/attachment.pgp> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages 2012-01-15 1:22 ` [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages Mike Frysinger @ 2012-02-26 0:19 ` David Wagner 2012-03-27 8:32 ` Anatolij Gustschin 0 siblings, 1 reply; 24+ messages in thread From: David Wagner @ 2012-02-26 0:19 UTC (permalink / raw) To: u-boot On 15/01/2012 02:22, Mike Frysinger wrote: > Acked-by: Mike Frysinger<vapier@gentoo.org> > -mike > Dear Wolfgang, I think Mike has acked all the 7 patches in v5. Thanks a lot if you can apply them. Regards, David Wagner. ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages 2012-02-26 0:19 ` David Wagner @ 2012-03-27 8:32 ` Anatolij Gustschin 2012-03-27 20:37 ` David Wagner 0 siblings, 1 reply; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:32 UTC (permalink / raw) To: u-boot Hello David, On Sun, 26 Feb 2012 01:19:39 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > On 15/01/2012 02:22, Mike Frysinger wrote: > > Acked-by: Mike Frysinger<vapier@gentoo.org> > > -mike > > > > Dear Wolfgang, > > I think Mike has acked all the 7 patches in v5. Thanks a lot if you can > apply them. I'll queue them in my staging branch. Thanks, Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages 2012-03-27 8:32 ` Anatolij Gustschin @ 2012-03-27 20:37 ` David Wagner 0 siblings, 0 replies; 24+ messages in thread From: David Wagner @ 2012-03-27 20:37 UTC (permalink / raw) To: u-boot On 27/03/2012 10:32, Anatolij Gustschin wrote: [...] > > I'll queue them in my staging branch. > > Thanks, > Anatolij Thanks a lot ! David. ^ permalink raw reply [flat|nested] 24+ messages in thread
* [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner ` (6 preceding siblings ...) 2012-01-15 1:22 ` [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages Mike Frysinger @ 2012-03-27 8:48 ` Anatolij Gustschin 7 siblings, 0 replies; 24+ messages in thread From: Anatolij Gustschin @ 2012-03-27 8:48 UTC (permalink / raw) To: u-boot On Sat, 14 Jan 2012 00:27:34 +0100 David Wagner <david.wagner@free-electrons.com> wrote: > Also, don't split error messages over several lines as per a coding style > exception making them easier to grep. > > Signed-off-by: David Wagner <david.wagner@free-electrons.com> > --- > tools/mkenvimage.c | 41 +++++++++++++++-------------------------- > 1 files changed, 15 insertions(+), 26 deletions(-) Applied to u-boot-staging/agust at denx.de with minor change. > @@ -118,7 +113,7 @@ int main(int argc, char **argv) > usage(prg); > return EXIT_SUCCESS; > case 'V': > - printf("%s version %s\n", prg, PLAIN_VERSION); > + printf("%s version %s\n", argv[0], PLAIN_VERSION); > return EXIT_SUCCESS; > case ':': > fprintf(stderr, "Missing argument for option -%c\n", I've dropped this hunk, since recently there was a patch to mkenvimage.c converting argv[0] to prg. Thanks, Anatolij ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2012-03-27 20:37 UTC | newest] Thread overview: 24+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-01-13 23:27 [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages David Wagner 2012-01-13 23:27 ` [U-Boot] [PATCHv5 2/7] mkenvimage: Correct an include and add a missing one David Wagner 2012-01-15 1:23 ` Mike Frysinger 2012-03-27 8:50 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 3/7] mkenvimage: More error handling David Wagner 2012-01-15 1:24 ` Mike Frysinger 2012-03-27 8:51 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 4/7] mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-" David Wagner 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 5/7] mkenvimage: Use mmap() when reading from a regular file David Wagner 2012-01-15 1:25 ` Mike Frysinger 2012-03-27 8:52 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 6/7] mkenvimage: Don't try to detect comments in the input file David Wagner 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 2012-01-13 23:27 ` [U-Boot] [PATCHv5 7/7] mkenvimage: Really set the redundant byte when applicable David Wagner 2012-01-15 1:26 ` Mike Frysinger 2012-03-27 8:53 ` Anatolij Gustschin 2012-01-15 1:22 ` [U-Boot] [PATCHv5 1/7] mkenvimage: correct and clarify comments and error messages Mike Frysinger 2012-02-26 0:19 ` David Wagner 2012-03-27 8:32 ` Anatolij Gustschin 2012-03-27 20:37 ` David Wagner 2012-03-27 8:48 ` Anatolij Gustschin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox