diff options
author | Denis Kenzior <denkenz@gmail.com> | 2011-05-22 06:35:01 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-05-24 12:10:22 -0500 |
commit | e8c7fc8a8adc7235bf20fe898f5bb14d0ab9b00f (patch) | |
tree | a54c305d354fc27ffa7a92ecee005680ce83a703 /gatchat | |
parent | 5405d0860f9578c97ca66716cb5f1a5478d8102f (diff) |
ppp_net: streamline ppp_net_new logic
Diffstat (limited to 'gatchat')
-rw-r--r-- | gatchat/ppp_net.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 52b35542..805ab59f 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -131,21 +131,12 @@ struct ppp_net *ppp_net_new(GAtPPP *ppp, int fd) int err; net = g_try_new0(struct ppp_net, 1); - if (net == NULL) { - if (fd >= 0) - close(fd); - - return NULL; - } + if (net == NULL) + goto badalloc; net->ppp_packet = ppp_packet_new(MAX_PACKET, PPP_IP_PROTO); - if (net->ppp_packet == NULL) { - if (fd >= 0) - close(fd); - - g_free(net); - return NULL; - } + if (net->ppp_packet == NULL) + goto error; /* * If the fd value is still the default one, @@ -195,12 +186,14 @@ error: if (channel) g_io_channel_unref(channel); - if (fd >= 0) - close(fd); - g_free(net->if_name); g_free(net->ppp_packet); g_free(net); + +badalloc: + if (fd >= 0) + close(fd); + return NULL; } |