[PATCH 30/30] util: dnsmasq: remove cleanup labels
Ján Tomko
jtomko at redhat.com
Tue Nov 24 12:40:08 UTC 2020
On a Monday in 2020, Ryan Gahagan wrote:
>From: Barrett Schonefeld <bschoney at utexas.edu>
>
>- src/util/virdnsmasq.c
>
>Signed-off-by: Barrett Schonefeld <bschoney at 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);
>
While VIR_FORCE_FCLOSE saves errno so it should preserve its value
> if (istmp)
> unlink(tmp);
that's not true for unlink, so this kind of usage of 'rc' is necessary.
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201124/7e00aa65/attachment-0001.sig>
More information about the libvir-list
mailing list