From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Cc: kernel@pengutronix.de
Subject: [PATCH] commands/crc: assert newline after output with big offsets
Date: Wed, 27 Jun 2012 11:08:33 +0200 [thread overview]
Message-ID: <1340788113-3171-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20120627082537.GE1623@pengutronix.de>
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
next prev parent reply other threads:[~2012-06-27 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Uwe Kleine-König [this message]
2012-07-17 8:23 ` [PATCH] commands/crc: assert newline after output with big offsets Uwe Kleine-König
2012-07-17 18:42 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340788113-3171-1-git-send-email-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=kernel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox