diff options
author | Richard Jones <rjones@redhat.com> | 2009-11-18 10:37:10 +0000 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-11-18 10:37:10 +0000 |
commit | f5a3da14837fe65eab1df41df33f2bafeddcd9ce (patch) | |
tree | 3dbd74ef7c72fe471fba77ae102efb7fd47ff9b5 /fuse | |
parent | 5c2da21b2ae56adc16bbd5bf9740a04ca70f9f19 (diff) | |
download | libguestfs-f5a3da14837fe65eab1df41df33f2bafeddcd9ce.tar.gz libguestfs-f5a3da14837fe65eab1df41df33f2bafeddcd9ce.tar.xz libguestfs-f5a3da14837fe65eab1df41df33f2bafeddcd9ce.zip |
generator: Fix API of functions that return RBufferOut
(NB: The API / ABI doesn't actually change here - it's just made much
simpler to use).
The API for RBufferOut functions was unexpectedly hard to use in the
case where a zero-length buffer might be returned. For discussion on
this see:
https://www.redhat.com/archives/libguestfs/2009-November/thread.html#00115
This commit ensures that in the zero-length buffer case, the return
value is never NULL. Thus code is now able to just check if the return
value == NULL to indicate an error, which is simpler for all concerned.
The implementation of this is, however, more complex because we have
to be careful about this case inside both the daemon and the library
code, which is what this commit does.
This has passed a full round of tests.
Diffstat (limited to 'fuse')
-rw-r--r-- | fuse/guestmount.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/fuse/guestmount.c b/fuse/guestmount.c index ba0d626c..baf2b667 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -620,14 +620,8 @@ fg_read (const char *path, char *buf, size_t size, off_t offset, if (size > limit) size = limit; - /* Note the correct error handling here is tricky, because in the - * case where the call returns a zero-length buffer, it might return - * NULL. However it won't adjust rsize along the error path, so we - * can set rsize to something beforehand and use that as a flag. - */ - rsize = 1; r = guestfs_pread (g, path, size, offset, &rsize); - if (rsize == 1 && r == NULL) + if (r == NULL) return error (); /* This should never happen, but at least it stops us overflowing |