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

Re: [Libguestfs] [PATCH libguestfs] daemon: diagnose socket write failure

On Thu, Aug 20, 2009 at 12:59:54PM +0200, Jim Meyering wrote:
> Ok, then by that argument, the preceding code that checks for encoding
> failure should also exit:
>     static int
>     send_chunk (const guestfs_chunk *chunk)
>     {
>       char buf[GUESTFS_MAX_CHUNK_SIZE + 48];
>       char lenbuf[4];
>       XDR xdr;
>       uint32_t len;
>       xdrmem_create (&xdr, buf, sizeof buf, XDR_ENCODE);
>       if (!xdr_guestfs_chunk (&xdr, (guestfs_chunk *) chunk)) {
>         fprintf (stderr, "send_chunk: failed to encode chunk\n");
>         xdr_destroy (&xdr);
>         return -1;
>       }
> However, if we do that, we might as well make the function void,
> since it will never return an error status.

Encoding failures can be non-fatal (arguably not in this case).  One
case where they can legitimately fail is if the data to be encoded in
the chunk exceeds the size of the fixed buffer (buf).

> But then, look at its two callers.
>   send_file_write currently tests for send_chunk failure
>   send_file_end does not
> Easy to adapt.  Just remove the test in send_file_end.
> Ok with all that?

Both should check the return value.  Whether they can do anything
useful about it is questionable though.


Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw

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