Hi Ravi, On Tue, Dec 17, 2013 at 12:05 AM, Ravi kumar Veeramally <ravikumar.veeramally@xxxxxxxxxxxxxxx> wrote: > Refacoring connect and disconnect mechanisms. It would be more > convinient for caller to maintain just bnep connection reference > and delete whenever it is not required. > --- > profiles/network/bnep.c | 37 +++++++++++++++++++++++++++++++++++++ > profiles/network/bnep.h | 5 +++++ > 2 files changed, 42 insertions(+) > > diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c > index 08037e6..d7d8832 100644 > --- a/profiles/network/bnep.c > +++ b/profiles/network/bnep.c > @@ -71,6 +71,7 @@ struct bnep_conn { > GIOChannel *io; > uint16_t src; > uint16_t dst; > + bdaddr_t dst_addr; > guint attempts; > guint setup_to; > void *data; > @@ -246,6 +247,42 @@ int bnep_if_down(const char *devname) > return 0; > } > > +struct bnep_conn *bnep_new(uint16_t src, uint16_t dst, > + const bdaddr_t *dst_addr) I would change the order of the parameters, also do not use bdaddr_t otherwise you wont be able to do unit tests with it, something like bnep_new(int fd, uint16_t local_role, uint16_t remote_role) looks better, but perhaps you gonna need the MTU as well. > +{ > + struct bnep_conn *bc; > + > + DBG(""); > + > + if (!dst_addr) > + return NULL; > + > + bc = g_new0(struct bnep_conn, 1); > + if (!bc) > + return NULL; No need to check the return of g_new0, if it fails it will exit so this code will never be triggered. -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html