mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
virsh: Use VIR_AUTOCLOSE more
There are few places where we can replace explicit VIR_FORCE_CLOSE() with VIR_AUTOCLOSE annotation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
f427e6c643
commit
1b2e06b1bf
@ -5539,7 +5539,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
|
||||
g_autoptr(virshDomain) dom = NULL;
|
||||
const char *name = NULL;
|
||||
char *file = NULL;
|
||||
int fd = -1;
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
g_autoptr(virshStream) st = NULL;
|
||||
unsigned int screen = 0;
|
||||
unsigned int flags = 0; /* currently unused */
|
||||
@ -5610,7 +5610,6 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
|
||||
unlink(file);
|
||||
if (generated)
|
||||
VIR_FREE(file);
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
VIR_FREE(mime);
|
||||
return ret;
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
|
||||
const char *file = NULL;
|
||||
g_autoptr(virshStorageVol) vol = NULL;
|
||||
bool ret = false;
|
||||
int fd = -1;
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
g_autoptr(virshStream) st = NULL;
|
||||
const char *name = NULL;
|
||||
unsigned long long offset = 0, length = 0;
|
||||
@ -731,7 +731,6 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -773,7 +772,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
|
||||
const char *file = NULL;
|
||||
g_autoptr(virshStorageVol) vol = NULL;
|
||||
bool ret = false;
|
||||
int fd = -1;
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
g_autoptr(virshStream) st = NULL;
|
||||
const char *name = NULL;
|
||||
unsigned long long offset = 0, length = 0;
|
||||
@ -846,7 +845,6 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
if (!ret && created)
|
||||
unlink(file);
|
||||
return ret;
|
||||
|
@ -2388,7 +2388,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
||||
{
|
||||
g_autofree char *ret = NULL;
|
||||
const char *tmpdir;
|
||||
int fd;
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
@ -2403,7 +2403,6 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
||||
if (safewrite(fd, doc, strlen(doc)) == -1) {
|
||||
vshError(ctl, _("write: %s: failed to write to temporary file: %s"),
|
||||
ret, g_strerror(errno));
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
unlink(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user