* [PATCH] commands/crc: add a trailing newline after output of checksum @ 2012-06-27 8:13 Uwe Kleine-König 2012-06-27 8:25 ` Sascha Hauer 0 siblings, 1 reply; 5+ messages in thread From: Uwe Kleine-König @ 2012-06-27 8:13 UTC (permalink / raw) To: barebox; +Cc: kernel Without this patch the next command prompt starts directly after the calculated check sum. While at it also fix the coding style. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- commands/crc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/crc.c b/commands/crc.c index df22941..81aa340 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -71,7 +71,7 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc, *total += now; } - printf ("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx", + printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx\n", filename, start, start + *total - 1, *crc); out_free: -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] commands/crc: add a trailing newline after output of checksum 2012-06-27 8:13 [PATCH] commands/crc: add a trailing newline after output of checksum Uwe Kleine-König @ 2012-06-27 8:25 ` Sascha Hauer 2012-06-27 9:08 ` [PATCH] commands/crc: assert newline after output with big offsets Uwe Kleine-König 0 siblings, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2012-06-27 8:25 UTC (permalink / raw) To: Uwe Kleine-König; +Cc: barebox, kernel On Wed, Jun 27, 2012 at 10:13:13AM +0200, Uwe Kleine-König wrote: > Without this patch the next command prompt starts directly after the > calculated check sum. While at it also fix the coding style. Under which conditions does this happen? The newline should be appended in do_crc() Sascha > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > commands/crc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/commands/crc.c b/commands/crc.c > index df22941..81aa340 100644 > --- a/commands/crc.c > +++ b/commands/crc.c > @@ -71,7 +71,7 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc, > *total += now; > } > > - printf ("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx", > + printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx\n", > filename, start, start + *total - 1, *crc); > > out_free: > -- > 1.7.10 > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] commands/crc: assert newline after output with big offsets 2012-06-27 8:25 ` Sascha Hauer @ 2012-06-27 9:08 ` Uwe Kleine-König 2012-07-17 8:23 ` Uwe Kleine-König 0 siblings, 1 reply; 5+ messages in thread From: Uwe Kleine-König @ 2012-06-27 9:08 UTC (permalink / raw) To: barebox; +Cc: kernel This fixes barebox@Very long board name:/ crc32 -f /dev/mem 0x83f00000+0xfff CRC32 for /dev/mem 0x83fff000 ... 0x83fffffe ==> 0xa080584bbarebox@Very long board name:/ The problem here was that the return value of lseek(fd, 0x83f00000, SEEK_SET) (which is 0x83f00000) was casted to an int (which is -2081423360), returned to do_crc and interpreted as error there without yielding another error message. This also makes crc32 -f /dev/mem 0xffffffff+0x1 die on a NULL pointer exception instead of reporting: lseek: No error :-) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- On Wed, Jun 27, 2012 at 10:25:37AM +0200, Sascha Hauer wrote: > On Wed, Jun 27, 2012 at 10:13:13AM +0200, Uwe Kleine-König wrote: > > Without this patch the next command prompt starts directly after the > > calculated check sum. While at it also fix the coding style. > > Under which conditions does this happen? The newline should be appended in > do_crc() You're right, my patch was not correct. This version should do the right thing now. Best regards Uwe commands/crc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/crc.c b/commands/crc.c index df22941..10a2900 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -47,9 +47,12 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc, } if (start > 0) { - ret = lseek(fd, start, SEEK_SET); - if (ret == -1) { + off_t lseek_ret; + errno = 0; + lseek_ret = lseek(fd, start, SEEK_SET); + if (lseek_ret == (off_t)-1 && errno) { perror("lseek"); + ret = -1; goto out; } } -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] commands/crc: assert newline after output with big offsets 2012-06-27 9:08 ` [PATCH] commands/crc: assert newline after output with big offsets Uwe Kleine-König @ 2012-07-17 8:23 ` Uwe Kleine-König 2012-07-17 18:42 ` Sascha Hauer 0 siblings, 1 reply; 5+ messages in thread From: Uwe Kleine-König @ 2012-07-17 8:23 UTC (permalink / raw) To: barebox; +Cc: kernel Hello Sascha, On Wed, Jun 27, 2012 at 11:08:33AM +0200, Uwe Kleine-König wrote: > This fixes > > barebox@Very long board name:/ crc32 -f /dev/mem 0x83f00000+0xfff > CRC32 for /dev/mem 0x83fff000 ... 0x83fffffe ==> 0xa080584bbarebox@Very long board name:/ > > The problem here was that the return value of > lseek(fd, 0x83f00000, SEEK_SET) (which is 0x83f00000) was casted to an > int (which is -2081423360), returned to do_crc and interpreted as > error there without yielding another error message. > > This also makes > > crc32 -f /dev/mem 0xffffffff+0x1 > > die on a NULL pointer exception instead of reporting: > > lseek: No error > > :-) > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > On Wed, Jun 27, 2012 at 10:25:37AM +0200, Sascha Hauer wrote: > > On Wed, Jun 27, 2012 at 10:13:13AM +0200, Uwe Kleine-König wrote: > > > Without this patch the next command prompt starts directly after the > > > calculated check sum. While at it also fix the coding style. > > > > Under which conditions does this happen? The newline should be appended in > > do_crc() > You're right, my patch was not correct. This version should do the right > thing now. ping > commands/crc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/commands/crc.c b/commands/crc.c > index df22941..10a2900 100644 > --- a/commands/crc.c > +++ b/commands/crc.c > @@ -47,9 +47,12 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc, > } > > if (start > 0) { > - ret = lseek(fd, start, SEEK_SET); > - if (ret == -1) { > + off_t lseek_ret; > + errno = 0; > + lseek_ret = lseek(fd, start, SEEK_SET); > + if (lseek_ret == (off_t)-1 && errno) { > perror("lseek"); > + ret = -1; > goto out; > } > } > -- > 1.7.10 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] commands/crc: assert newline after output with big offsets 2012-07-17 8:23 ` Uwe Kleine-König @ 2012-07-17 18:42 ` Sascha Hauer 0 siblings, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2012-07-17 18:42 UTC (permalink / raw) To: Uwe Kleine-König; +Cc: barebox, kernel On Tue, Jul 17, 2012 at 10:23:53AM +0200, Uwe Kleine-König wrote: > Hello Sascha, > > > You're right, my patch was not correct. This version should do the right > > thing now. > ping Applied, thanks Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-17 18:43 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-27 8:13 [PATCH] commands/crc: add a trailing newline after output of checksum Uwe Kleine-König 2012-06-27 8:25 ` Sascha Hauer 2012-06-27 9:08 ` [PATCH] commands/crc: assert newline after output with big offsets Uwe Kleine-König 2012-07-17 8:23 ` Uwe Kleine-König 2012-07-17 18:42 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox