[libvirt] [PATCH] eliminate possibility of a double-closed file descriptor

The 2nd and 3rd hunk show the only double-closed file descriptor code part that I found while trying to clean up close(). The first hunk seems a harmless cleanup in that same file. Signed-off-by: Stefan Berger <stefanb@us.ibm.com> Index: Stefan/src/storage/storage_backend_logical.c =================================================================== --- Stefan.orig/src/storage/storage_backend_logical.c +++ Stefan/src/storage/storage_backend_logical.c @@ -37,6 +37,7 @@ #include "util.h" #include "memory.h" #include "logging.h" +#include "files.h" #define VIR_FROM_THIS VIR_FROM_STORAGE @@ -408,10 +409,10 @@ virStorageBackendLogicalBuildPool(virCon virReportSystemError(errno, _("cannot clear device header of '%s'"), pool->def->source.devices[i].path); - close(fd); + VIR_FORCE_CLOSE(fd); goto cleanup; } - if (close(fd) < 0) { + if (VIR_CLOSE(fd) < 0) { virReportSystemError(errno, _("cannot close device '%s'"), pool->def->source.devices[i].path); @@ -622,7 +623,7 @@ virStorageBackendLogicalCreateVol(virCon goto cleanup; } - if (close(fd) < 0) { + if (VIR_CLOSE(fd) < 0) { virReportSystemError(errno, _("cannot close file '%s'"), vol->target.path); @@ -641,8 +642,7 @@ virStorageBackendLogicalCreateVol(virCon return 0; cleanup: - if (fd != -1) - close(fd); + VIR_FORCE_CLOSE(fd); virStorageBackendLogicalDeleteVol(conn, pool, vol, 0); return -1; }

On 10/28/2010 05:22 AM, Stefan Berger wrote:
The 2nd and 3rd hunk show the only double-closed file descriptor code part that I found while trying to clean up close(). The first hunk seems a harmless cleanup in that same file.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake <eblake@redhat.com> wrote on 10/28/2010 10:58:47 AM:
On 10/28/2010 05:22 AM, Stefan Berger wrote:
The 2nd and 3rd hunk show the only double-closed file descriptor code
part
that I found while trying to clean up close(). The first hunk seems a harmless cleanup in that same file.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
ACK.
Pushed.
participants (2)
-
Eric Blake
-
Stefan Berger