[Libreoffice] [PATCH]: fixes compiler warnings for vcl/workben/svpclient.cxx
tlillqvist at novell.com
Mon May 23 07:04:28 PDT 2011
> Together with svptest, it excersises the headless mode - so you can
> watch vcl render to some framebuffer device. Still useful code.
OK. So shouldn't we then fix the code to work correctly, not just get rid of compiler warnings?
+ nBytes = write( nSocket, rCommand.getStr(), rCommand.getLength() );
+ if( nBytes < rCommand.getLength() )
+ perror( "SvpElementContainer: write() failed" );
just calling perror() isn't right in case less bytes were written than requested; that is a perfectly valid situation (even if perhaps rare, for "sane" lengths and "normal" networks) . It is only if write() returns -1 that it has failed, a partial write is not an error.
The code should either 1) not bother to handle the partial write case, handle it like a write() failure, and then exit(1) in addition to the perror(), or 2) exit on write error, but handle partial writes by looping until everything has been written. Just continuing as if everything requested was written when the return value indicates it wasn't is wrong.
More information about the LibreOffice