From cc5c4ac6ddbc468a4083ccd5a9e1ab2aed409e64 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 17 Aug 2001 13:18:01 +0000 Subject: 2001-08-16 Joel Sherrill * libc/lseek.c: Modified after discussion with Eugeny S. Mints to correct the behavior. There were two mistakes. First, iop->offset was incorrectly set for SEEK_END. Second, iop->offset should be left unmodified if there are errors. This modification attempts to fix both situations. --- c/src/exec/libcsupport/src/lseek.c | 5 ++--- c/src/lib/libc/lseek.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'c') diff --git a/c/src/exec/libcsupport/src/lseek.c b/c/src/exec/libcsupport/src/lseek.c index 910b81d231..af41116346 100644 --- a/c/src/exec/libcsupport/src/lseek.c +++ b/c/src/exec/libcsupport/src/lseek.c @@ -68,14 +68,13 @@ off_t lseek( */ status = (*iop->handlers->lseek_h)( iop, offset, whence ); - if ( !status ) - return 0; + if ( status == (off_t) -1 ) + iop->offset = old_offset; /* * So if the operation failed, we have to restore iop->offset. */ - iop->offset = old_offset; return status; } diff --git a/c/src/lib/libc/lseek.c b/c/src/lib/libc/lseek.c index 910b81d231..af41116346 100644 --- a/c/src/lib/libc/lseek.c +++ b/c/src/lib/libc/lseek.c @@ -68,14 +68,13 @@ off_t lseek( */ status = (*iop->handlers->lseek_h)( iop, offset, whence ); - if ( !status ) - return 0; + if ( status == (off_t) -1 ) + iop->offset = old_offset; /* * So if the operation failed, we have to restore iop->offset. */ - iop->offset = old_offset; return status; } -- cgit v1.2.3