Re: gnome_vfs_read returns EOF when requesting zero bytes



On Mon, 2005-02-21 at 16:33 +0100, Johan Ersvik wrote:
> On Mon, 2005-02-21 at 11:25 +0100, Mathieu Lacage wrote:
> >On Mon, 2005-02-21 at 08:59 +0100, Alexander Larsson wrote:
> >> On Sat, 2005-02-19 at 17:26 +0100, Johan Ersvik wrote:
> >> > Hi,
> >> > I noticed that the call gnome_vfs_read(handle, buffer, 0, &nchars)
> >> > returns GNOME_VFS_ERROR_EOF. Is this on purpose or just a boundary case
> >> > that has gone unnoticed? The documentation didn't clear things up much
> >> > either. Rather it implies that the above call should return
> >> > GNOME_VFS_OK.
> >> 
> >> I  consider this a bug. 
> >> 
> >> However, in the case where we have actually reached EOF, what should it
> >> return then? I guess returning GNOME_VFS_OK in this case is ok too,
> >> since you might say the operation succeeds before "reaching" the end of
> >> the file.
> >
> >yes. I believe the semantics are that EOF is raised only when you try to
> >read past the end of the file.
> >
> >Mathieu
> 
> I agree. So should we fix this in gnome_vfs_read,
> gnome_vfs_read_cancellable or directly in the affected modules? Can I
> send a patch somewhere (bugzilla/list) or does any commit authorized
> person feel like just adding the check? :)

I'm commiting this:

Index: libgnomevfs/gnome-vfs-cancellable-ops.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-cancellable-ops.c,v
retrieving revision 1.31
diff -u -p -r1.31 gnome-vfs-cancellable-ops.c
--- libgnomevfs/gnome-vfs-cancellable-ops.c     11 Mar 2004 08:06:30 -0000      1.31
+++ libgnomevfs/gnome-vfs-cancellable-ops.c     22 Feb 2005 08:03:45 -0000
@@ -125,6 +125,11 @@ gnome_vfs_read_cancellable (GnomeVFSHand
                bytes_read = &dummy_bytes_read;
        }

+       if (bytes == 0) {
+               *bytes_read = 0;
+               return GNOME_VFS_OK;
+       }
+
        return _gnome_vfs_handle_do_read (handle, buffer, bytes, bytes_read,
                                         context);
 }
@@ -147,6 +152,11 @@ gnome_vfs_write_cancellable (GnomeVFSHan
                bytes_written = &dummy_bytes_written;
        }

+       if (bytes == 0) {
+               *bytes_written = 0;
+               return GNOME_VFS_OK;
+       }
+
        return _gnome_vfs_handle_do_write (handle, buffer, bytes,
                                          bytes_written, context);
 }

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a maverick guitar-strumming firefighter with no name. She's a mistrustful 
gold-digging politician who don't take no shit from nobody. They fight crime! 




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