bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] fseeko: remove unneeded hack


From: Eric Blake
Subject: [PATCH 2/2] fseeko: remove unneeded hack
Date: Tue, 9 Aug 2011 15:52:54 -0600

Now that the fixed fseeko doesn't fail, we can remove the hack
that was previously making the testsuite pass.

* tests/test-fflush2.c (main): Don't special-case SEEK_END.

Signed-off-by: Eric Blake <address@hidden>
---

I'll let Bruno commit any additional testsuite improvements.

I tested that if these two patches are applied in reverse order,
then the testsuite does indeed flag failure on glibc, where
rpc_fseeko was used but failed to update the stream offset correctly.

 ChangeLog    |    3 +++
 lib/fseeko.c |   17 +++++------------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0917f5e..455a699 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-08-09  Eric Blake  <address@hidden>

+       fseeko: remove unneeded hack
+       * tests/test-fflush2.c (main): Don't special-case SEEK_END.
+
        fseeko: fix bug on glibc
        * lib/fseeko.c (fseeko): Set stream offset to match fd offset.
        Reported by John W. Eaton.
diff --git a/lib/fseeko.c b/lib/fseeko.c
index 80ca1e0..83834a0 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -93,14 +93,10 @@ fseeko (FILE *fp, off_t offset, int whence)
   #error "Please port gnulib fseeko.c to your platform! Look at the code in 
fpurge.c, then report this to bug-gnulib."
 #endif
     {
-      /* We get here when an fflush() call immediately preceded this one.  We
-         know there are no buffers.
-         POSIX requires us to modify the file descriptor's position.
-         But we cannot position beyond end of file here.  */
-      off_t pos =
-        lseek (fileno (fp),
-               whence == SEEK_END && offset > 0 ? 0 : offset,
-               whence);
+      /* We get here when an fflush() call immediately preceded this one (or
+         if ftell() has created buffers but no I/O has occurred on a
+         newly-opened stream).  We know there are no buffers.  */
+      off_t pos = lseek (fileno (fp), offset, whence);
       if (pos == -1)
         {
 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
@@ -141,10 +137,7 @@ fseeko (FILE *fp, off_t offset, int whence)
       fp->__offset = pos;
       fp->__eof = 0;
 #endif
-      /* If we were not requested to position beyond end of file, we're
-         done.  */
-      if (!(whence == SEEK_END && offset > 0))
-        return 0;
+      return 0;
     }
   return fseeko (fp, offset, whence);
 }
-- 
1.7.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]