aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/src/interfaces/updown/updown.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-31 17:02:17 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-31 17:12:00 +0100
commit29bb779084d76fb31e1b5dfbf54995918d02fc0e (patch)
tree3196a6755573609a3e6125d8792da8bb4e8de8c4 /ctrl/facemgr/src/interfaces/updown/updown.c
parent5268f318730bd8f3ffaf62e5d6bfae64eb17cb90 (diff)
[HICN-372] Code clean up
Change-Id: Ic0ce2d01a05c2724eeaf91f76aafa2facedcbaf3 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr/src/interfaces/updown/updown.c')
-rw-r--r--ctrl/facemgr/src/interfaces/updown/updown.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ctrl/facemgr/src/interfaces/updown/updown.c b/ctrl/facemgr/src/interfaces/updown/updown.c
index 6a7ab83f4..b804cdac1 100644
--- a/ctrl/facemgr/src/interfaces/updown/updown.c
+++ b/ctrl/facemgr/src/interfaces/updown/updown.c
@@ -53,7 +53,7 @@ int updown_initialize(interface_t * interface, void * cfg)
data->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (data->fd == -1) {
perror("socket error");
- return -1;
+ goto ERR_SOCKET;
}
memset(&addr, 0, sizeof(addr));
@@ -67,7 +67,7 @@ int updown_initialize(interface_t * interface, void * cfg)
if (connect(data->fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
perror("connect error");
- return -1;
+ goto ERR_CONNECT;
}
if (interface_register_fd(interface, data->fd, NULL) < 0) {
@@ -77,6 +77,11 @@ int updown_initialize(interface_t * interface, void * cfg)
return 0;
+ERR_FD:
+ERR_CONNECT:
+ close(data->fd);
+ERR_SOCKET:
+ free(data);
ERR_MALLOC:
return -1;
}
@@ -87,11 +92,12 @@ int updown_finalize(interface_t * interface)
if (data->fd > 0)
close(data->fd);
+ free(data);
return 0;
}
-int updown_callback(interface_t * interface)
+int updown_callback(interface_t * interface, int fd, void * unused)
{
updown_data_t * data = (updown_data_t*)interface->data;
char buf[100];