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>
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 */
unlink(file);
if (generated)
VIR_FREE(file);
- VIR_FORCE_CLOSE(fd);
VIR_FREE(mime);
return ret;
}
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;
ret = true;
cleanup:
- VIR_FORCE_CLOSE(fd);
return ret;
}
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;
ret = true;
cleanup:
- VIR_FORCE_CLOSE(fd);
if (!ret && created)
unlink(file);
return ret;
{
g_autofree char *ret = NULL;
const char *tmpdir;
- int fd;
+ VIR_AUTOCLOSE fd = -1;
tmpdir = getenv("TMPDIR");
if (!tmpdir) tmpdir = "/tmp";
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;
}