diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-18 11:14:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-18 11:19:04 +0200 |
commit | 831be2ecee569275b9e32711613ec6ef0567b566 (patch) | |
tree | 60e55db3f46c27ae244ca1e3cc9bd46dd644cd1a /commands/mem.c | |
parent | c46a84104952d24e89467f83791e0bc72615d0fe (diff) | |
download | barebox-831be2ecee569275b9e32711613ec6ef0567b566.tar.gz barebox-831be2ecee569275b9e32711613ec6ef0567b566.tar.xz |
lseek: return -1 instead of -errno
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>
Diffstat (limited to 'commands/mem.c')
-rw-r--r-- | commands/mem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/commands/mem.c b/commands/mem.c index f32e5d8299..080bfdef3f 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; |