Return-Path: MIME-Version: 1.0 In-Reply-To: References: <1385649955-29276-1-git-send-email-ravikumar.veeramally@linux.intel.com> <1385649955-29276-2-git-send-email-ravikumar.veeramally@linux.intel.com> Date: Thu, 28 Nov 2013 18:12:19 +0200 Message-ID: Subject: Re: [PATCH_v2 1/7] profiles/network: Remove redundant code for bnep interface name From: Luiz Augusto von Dentz To: Anderson Lizardo Cc: Ravi kumar Veeramally , BlueZ development Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi, On Thu, Nov 28, 2013 at 5:52 PM, Anderson Lizardo wrote: > Hi Ravi, > > On Thu, Nov 28, 2013 at 10:45 AM, Ravi kumar Veeramally > wrote: >> Remove redundant code for copying bnepX interface name from connection >> and server files. It is better to place on actual function call. >> --- >> profiles/network/common.c | 3 +-- >> profiles/network/connection.c | 2 -- >> profiles/network/server.c | 3 --- >> 3 files changed, 1 insertion(+), 7 deletions(-) >> >> diff --git a/profiles/network/common.c b/profiles/network/common.c >> index 0b291bd..b94b3a5 100644 >> --- a/profiles/network/common.c >> +++ b/profiles/network/common.c >> @@ -150,8 +150,7 @@ int bnep_connadd(int sk, uint16_t role, char *dev) >> struct bnep_connadd_req req; >> >> memset(&req, 0, sizeof(req)); >> - strncpy(req.device, dev, 16); >> - req.device[15] = '\0'; >> + strcpy(req.device, "bnep%d"); >> req.sock = sk; >> req.role = role; >> if (ioctl(ctl, BNEPCONNADD, &req) < 0) { >> diff --git a/profiles/network/connection.c b/profiles/network/connection.c >> index 5966268..301f66d 100644 >> --- a/profiles/network/connection.c >> +++ b/profiles/network/connection.c >> @@ -692,8 +692,6 @@ int connection_register(struct btd_service *service) >> >> nc = g_new0(struct network_conn, 1); >> nc->id = id; >> - memset(nc->dev, 0, sizeof(nc->dev)); >> - strcpy(nc->dev, "bnep%d"); >> nc->service = btd_service_ref(service); >> nc->state = DISCONNECTED; >> nc->peer = peer; >> diff --git a/profiles/network/server.c b/profiles/network/server.c >> index 0050b30..3a7e52a 100644 >> --- a/profiles/network/server.c >> +++ b/profiles/network/server.c >> @@ -269,9 +269,6 @@ static int server_connadd(struct network_server *ns, >> char devname[16]; >> int err, nsk; >> >> - memset(devname, 0, sizeof(devname)); >> - strcpy(devname, "bnep%d"); >> - >> nsk = g_io_channel_unix_get_fd(session->io); >> err = bnep_connadd(nsk, dst_role, devname); > > You are still passing a (now uninitialized) devname pointer to > bnep_connadd(). Is this still necessary? Well either bnep_connadd has to return the interface name or we should pass as reference so it get initialized inside bnep_connadd in case of success. -- Luiz Augusto von Dentz