Discussion:
[PATCH] ifdown: if socket can not be opened, then no need to close it
Pingfan Liu
2017-02-28 08:10:01 UTC
Permalink
Signed-off-by: Pingfan Liu <***@redhat.com>
---
kexec/ifdown.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kexec/ifdown.c b/kexec/ifdown.c
index 9679ad7..a5067ae 100644
--- a/kexec/ifdown.c
+++ b/kexec/ifdown.c
@@ -34,7 +34,7 @@ int ifdown(void)
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
fprintf(stderr, "ifdown: ");
perror("socket");
- goto error;
+ goto exit;
}

if ((ifa = if_nameindex()) == NULL) {
@@ -74,5 +74,6 @@ int ifdown(void)

error:
close(fd);
+exit:
return -1;
}
--
2.7.4
Pratyush Anand
2017-03-01 06:26:48 UTC
Permalink
Post by Pingfan Liu
---
kexec/ifdown.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kexec/ifdown.c b/kexec/ifdown.c
index 9679ad7..a5067ae 100644
--- a/kexec/ifdown.c
+++ b/kexec/ifdown.c
@@ -34,7 +34,7 @@ int ifdown(void)
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
fprintf(stderr, "ifdown: ");
perror("socket");
- goto error;
+ goto exit;
may be 'return -1 ' from here itself..

anyway..both are fine.
Post by Pingfan Liu
}
if ((ifa = if_nameindex()) == NULL) {
@@ -74,5 +74,6 @@ int ifdown(void)
close(fd);
return -1;
}
Reviewed-by: Pratyush Anand <***@redhat.com>

Loading...