mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] lseek: return -1 instead of -errno
Date: Fri, 18 May 2012 11:17:48 +0200	[thread overview]
Message-ID: <1337332668-13419-1-git-send-email-s.hauer@pengutronix.de> (raw)

The patch making errno a positive value has another bug:
lseek was switched to return -errno instead of -1. This does not
work since we can lseek we can address the whole 4G address space,
have of which has a negative offset when interpreted as a signed
integer. Let lseek return -1 on failure again instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/crc.c |    2 +-
 commands/mem.c |    4 ++--
 fs/fs.c        |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/commands/crc.c b/commands/crc.c
index a0d3af6..df22941 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -48,7 +48,7 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc,
 
 	if (start > 0) {
 		ret = lseek(fd, start, SEEK_SET);
-		if (ret < 0) {
+		if (ret == -1) {
 			perror("lseek");
 			goto out;
 		}
diff --git a/commands/mem.c b/commands/mem.c
index f32e5d8..080bfde 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -122,10 +122,10 @@ static int open_and_lseek(const char *filename, int mode, off_t pos)
 		return fd;
 
 	ret = lseek(fd, pos, SEEK_SET);
-	if (ret < 0) {
+	if (ret == -1) {
 		perror("lseek");
 		close(fd);
-		return ret;
+		return -errno;
 	}
 
 	return fd;
diff --git a/fs/fs.c b/fs/fs.c
index e5ae6d5..9cda1d9 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -732,13 +732,13 @@ off_t lseek(int fildes, off_t offset, int whence)
 		goto out;
 	}
 
-	ret = fsdrv->lseek(dev, f, pos);
+	return fsdrv->lseek(dev, f, pos);
 
 out:
 	if (ret)
 		errno = -ret;
 
-	return ret;
+	return -1;
 }
 EXPORT_SYMBOL(lseek);
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2012-05-18  9:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1337332668-13419-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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