[libvirt] [PATCH v3] bye to close(), welcome to VIR_(FORCE_)CLOSE()

Daniel P. Berrange berrange at redhat.com
Tue Nov 9 10:58:17 UTC 2010


On Mon, Nov 08, 2010 at 03:17:56PM -0700, Eric Blake wrote:
> > Index: libvirt-acl/src/libvirt.c
> > ===================================================================
> > --- libvirt-acl.orig/src/libvirt.c
> > +++ libvirt-acl/src/libvirt.c
> > @@ -10794,7 +10794,7 @@ virStreamRef(virStreamPtr stream)
> >   *      ... report an error ....
> >   * done:
> >   *   virStreamFree(st);
> > - *   close(fd);
> > + *   VIR_FORCE_CLOSE(fd);
> >   *
> >   * Returns the number of bytes written, which may be less
> >   * than requested.
> > @@ -10884,8 +10884,8 @@ error:
> >   *      ... report an error ....
> >   * done:
> >   *   virStreamFree(st);
> > - *   close(fd);
> > - *
> > + *   if (VIR_CLOSE(fd) < 0)
> > + *       virReportSystemError(errno, "%s", _("failed to close file"));
> >   *
> >   * Returns the number of bytes read, which may be less
> >   * than requested.
> > @@ -10964,7 +10964,7 @@ error:
> >   *   if (virStreamFinish(st) < 0)
> >   *      ...report an error...
> >   *   virStreamFree(st);
> > - *   close(fd);
> > + *   VIR_FORCE_CLOSE(fd);
> >   *
> >   * Returns 0 if all the data was successfully sent. The caller
> >   * should invoke virStreamFinish(st) to flush the stream upon
> 
> These first three are okay.
> 
> > @@ -11061,7 +11061,7 @@ cleanup:
> >   *   if (virStreamFinish(st) < 0)
> >   *      ...report an error...
> >   *   virStreamFree(st);
> > - *   close(fd);
> > + *   VIR_FORCE_CLOSE(fd);
> 
> But the comment for virStreamRecvAll should match the comment for
> virStreamRecv.  (Comments only, so trivial to fix).


None of these comments should be changed. They are illustrating how to
use the libvirt public API from application code. Application code
will not have VIR_CLOSE/VIR_FORCE_CLOSE since that's libvirt internal
stuff.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list