From: Barrett Schonefeld <bschoney(a)utexas.edu>
- src/util/virdnsmasq.c
Signed-off-by: Barrett Schonefeld <bschoney(a)utexas.edu>
---
src/util/virdnsmasq.c | 46 +++++++++++++------------------------------
1 file changed, 14 insertions(+), 32 deletions(-)
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index 5f477c976d..b41cdb8047 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -168,7 +168,6 @@ addnhostsWrite(const char *path,
FILE *f;
bool istmp = true;
size_t i, j;
- int rc = 0;
/* even if there are 0 hosts, create a 0 length file, to allow
* for runtime addition.
@@ -179,58 +178,51 @@ addnhostsWrite(const char *path,
if (!(f = fopen(tmp, "w"))) {
istmp = false;
if (!(f = fopen(path, "w"))) {
- rc = -errno;
- goto cleanup;
+ return -errno;
}
}
for (i = 0; i < nhosts; i++) {
if (fputs(hosts[i].ip, f) == EOF || fputc('\t', f) == EOF) {
- rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
unlink(tmp);
- goto cleanup;
+ return -errno;
}
for (j = 0; j < hosts[i].nhostnames; j++) {
if (fputs(hosts[i].hostnames[j], f) == EOF || fputc('\t', f) == EOF)
{
- rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
unlink(tmp);
- goto cleanup;
+ return -errno;
}
}
if (fputc('\n', f) == EOF) {
- rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
unlink(tmp);
- goto cleanup;
+ return -errno;
}
}
if (VIR_FCLOSE(f) == EOF) {
- rc = -errno;
- goto cleanup;
+ return -errno;
}
if (istmp && rename(tmp, path) < 0) {
- rc = -errno;
unlink(tmp);
- goto cleanup;
+ return -errno;
}
- cleanup:
- return rc;
+ return 0;
}
static int
@@ -366,7 +358,6 @@ hostsfileWrite(const char *path,
FILE *f;
bool istmp = true;
size_t i;
- int rc = 0;
/* even if there are 0 hosts, create a 0 length file, to allow
* for runtime addition.
@@ -377,36 +368,31 @@ hostsfileWrite(const char *path,
if (!(f = fopen(tmp, "w"))) {
istmp = false;
if (!(f = fopen(path, "w"))) {
- rc = -errno;
- goto cleanup;
+ return -errno;
}
}
for (i = 0; i < nhosts; i++) {
if (fputs(hosts[i].host, f) == EOF || fputc('\n', f) == EOF) {
- rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
unlink(tmp);
- goto cleanup;
+ return -errno;
}
}
if (VIR_FCLOSE(f) == EOF) {
- rc = -errno;
- goto cleanup;
+ return -errno;
}
if (istmp && rename(tmp, path) < 0) {
- rc = -errno;
unlink(tmp);
- goto cleanup;
+ return -errno;
}
- cleanup:
- return rc;
+ return 0;
}
static int
@@ -681,16 +667,12 @@ dnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const char *buf)
static int
dnsmasqCapsSetFromFile(dnsmasqCapsPtr caps, const char *path)
{
- int ret = -1;
g_autofree char *buf = NULL;
if (virFileReadAll(path, 1024 * 1024, &buf) < 0)
- goto cleanup;
-
- ret = dnsmasqCapsSetFromBuffer(caps, buf);
+ return -1;
- cleanup:
- return ret;
+ return dnsmasqCapsSetFromBuffer(caps, buf);
}
static int
--
2.29.0