Skip to contentSkip to conversation

ifdown: if socket can not be opened, then no need to close it

PATCH In review Pingfan Liu 2 participants 2 messages Feb 28, 2017 – Mar 1, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ifdown: if socket can not be opened, then no need to close it

---
 kexec/ifdown.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kexec/ifdown.c +2 -1
index 9679ad7..a5067ae 100644
@@ -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;
 }
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pingfan Liu
---
 kexec/ifdown.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kexec/ifdown.c +0 -0
index 9679ad7..a5067ae 100644

kexec/ifdown.c int ifdown(void) · line 37

Quoted 5 lines
kexec/ifdown.c +1 -1
@@ -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.

kexec/ifdown.c int ifdown(void) · line 79

Quoted 11 lines
kexec/ifdown.c +1 -0
 	}
 
 	if ((ifa = if_nameindex()) == NULL) {
@@ -74,5 +74,6 @@ int ifdown(void)
 
 error:
 	close(fd);
+exit:
 	return -1;
 }

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec