public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: Fix memory leaks
@ 2009-02-09  3:15 Gustavo F. Padovan
  2009-02-09 12:31 ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo F. Padovan @ 2009-02-09  3:15 UTC (permalink / raw)
  To: linux-bluetooth

Some printfs was using as parameter functions that return dinamic
allocated memory. Now, we free them!

Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
 tools/hciconfig.c |   15 ++++++++++++---
 tools/hcitool.c   |    6 ++++--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 960f450..ca7394f 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -85,7 +85,10 @@ static void print_dev_list(int ctl, int flags)
 
 static void print_pkt_type(struct hci_dev_info *di)
 {
-	printf("\tPacket type: %s\n", hci_ptypetostr(di->pkt_type));
+	char *str;
+	str = hci_ptypetostr(di->pkt_type);
+	printf("\tPacket type: %s\n", str);
+	bt_free(str);
 }
 
 static void print_link_policy(struct hci_dev_info *di)
@@ -95,7 +98,10 @@ static void print_link_policy(struct hci_dev_info *di)
 
 static void print_link_mode(struct hci_dev_info *di)
 {
-	printf("\tLink mode: %s\n", hci_lmtostr(di->link_mode));
+	char *str;
+	str =  hci_lmtostr(di->link_mode);
+	printf("\tLink mode: %s\n", str);
+	bt_free(str);
 }
 
 static void print_dev_features(struct hci_dev_info *di, int format)
@@ -1586,10 +1592,13 @@ static void print_dev_hdr(struct hci_dev_info *di)
 static void print_dev_info(int ctl, struct hci_dev_info *di)
 {
 	struct hci_dev_stats *st = &di->stat;
+	char * str;
 
 	print_dev_hdr(di);
 
-	printf("\t%s\n", hci_dflagstostr(di->flags) );
+	str = hci_dflagstostr(di->flags);
+	printf("\t%s\n", str);
+	bt_free(str);
 
 	printf("\tRX bytes:%d acl:%d sco:%d events:%d errors:%d\n",
 		st->byte_rx, st->acl_rx, st->sco_rx, st->evt_rx, st->err_rx);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index e24bde9..f1cffb6 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -102,11 +102,13 @@ static int conn_list(int s, int dev_id, long arg)
 
 	for (i = 0; i < cl->conn_num; i++, ci++) {
 		char addr[18];
+		char * str;
 		ba2str(&ci->bdaddr, addr);
+		str = hci_lmtostr(ci->link_mode);
 		printf("\t%s %s %s handle %d state %d lm %s\n",
 			ci->out ? "<" : ">", type2str(ci->type),
-			addr, ci->handle, ci->state,
-			hci_lmtostr(ci->link_mode));
+			addr, ci->handle, ci->state, str);
+		bt_free(str);
 	}
 
 	return 0;
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools: Fix memory leaks
  2009-02-09  3:15 [PATCH] tools: Fix memory leaks Gustavo F. Padovan
@ 2009-02-09 12:31 ` Marcel Holtmann
  2009-02-09 13:28   ` Gustavo F. Padovan
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-02-09 12:31 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth

Hi Gustavo,

> Some printfs was using as parameter functions that return dinamic
> allocated memory. Now, we free them!
> 
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>

BlueZ doesn't use Signed-off-by for commit messages. That is kernel
stuff.

> @@ -1586,10 +1592,13 @@ static void print_dev_hdr(struct hci_dev_info *di)
>  static void print_dev_info(int ctl, struct hci_dev_info *di)
>  {
>  	struct hci_dev_stats *st = &di->stat;
> +	char * str;

This needs to be "char *str;"

Please fix it and re-sent the patch.

Regards

Marcel



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools: Fix memory leaks
  2009-02-09 12:31 ` Marcel Holtmann
@ 2009-02-09 13:28   ` Gustavo F. Padovan
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo F. Padovan @ 2009-02-09 13:28 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

On Mon, Feb 9, 2009 at 10:31 AM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Gustavo,
>
>> Some printfs was using as parameter functions that return dinamic
>> allocated memory. Now, we free them!
>>
>> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
>
> BlueZ doesn't use Signed-off-by for commit messages. That is kernel
> stuff.
>
>> @@ -1586,10 +1592,13 @@ static void print_dev_hdr(struct hci_dev_info *d=
i)
>>  static void print_dev_info(int ctl, struct hci_dev_info *di)
>>  {
>>       struct hci_dev_stats *st =3D &di->stat;
>> +     char * str;
>
> This needs to be "char *str;"
>
> Please fix it and re-sent the patch.

Ok.

>
> Regards
>
> Marcel
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



--=20
----------------------------------------------
Gustavo Fernando Padovan
Engenharia de Computa=E7=E3o 2006
Instituto de Computa=E7=E3o - UNICAMP

gfpadovan@gmail.com
gustavo@las.ic.unicamp.br
-------------------------------------------

Seja Livre, use Software Livre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] tools: Fix memory leaks
@ 2009-02-09 23:50 Gustavo F. Padovan
  2009-02-10 15:43 ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo F. Padovan @ 2009-02-09 23:50 UTC (permalink / raw)
  To: linux-bluetooth

Some printfs was using as parameter functions that return dinamic
allocated memory. Now, we free them!

---
 tools/hciconfig.c |   15 ++++++++++++---
 tools/hcitool.c   |    6 ++++--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 960f450..a89aed1 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -85,7 +85,10 @@ static void print_dev_list(int ctl, int flags)
 
 static void print_pkt_type(struct hci_dev_info *di)
 {
-	printf("\tPacket type: %s\n", hci_ptypetostr(di->pkt_type));
+	char *str;
+	str = hci_ptypetostr(di->pkt_type);
+	printf("\tPacket type: %s\n", str);
+	bt_free(str);
 }
 
 static void print_link_policy(struct hci_dev_info *di)
@@ -95,7 +98,10 @@ static void print_link_policy(struct hci_dev_info *di)
 
 static void print_link_mode(struct hci_dev_info *di)
 {
-	printf("\tLink mode: %s\n", hci_lmtostr(di->link_mode));
+	char *str;
+	str =  hci_lmtostr(di->link_mode);
+	printf("\tLink mode: %s\n", str);
+	bt_free(str);
 }
 
 static void print_dev_features(struct hci_dev_info *di, int format)
@@ -1586,10 +1592,13 @@ static void print_dev_hdr(struct hci_dev_info *di)
 static void print_dev_info(int ctl, struct hci_dev_info *di)
 {
 	struct hci_dev_stats *st = &di->stat;
+	char *str;
 
 	print_dev_hdr(di);
 
-	printf("\t%s\n", hci_dflagstostr(di->flags) );
+	str = hci_dflagstostr(di->flags);
+	printf("\t%s\n", str);
+	bt_free(str);
 
 	printf("\tRX bytes:%d acl:%d sco:%d events:%d errors:%d\n",
 		st->byte_rx, st->acl_rx, st->sco_rx, st->evt_rx, st->err_rx);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index e24bde9..faf4cb4 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -102,11 +102,13 @@ static int conn_list(int s, int dev_id, long arg)
 
 	for (i = 0; i < cl->conn_num; i++, ci++) {
 		char addr[18];
+		char *str;
 		ba2str(&ci->bdaddr, addr);
+		str = hci_lmtostr(ci->link_mode);
 		printf("\t%s %s %s handle %d state %d lm %s\n",
 			ci->out ? "<" : ">", type2str(ci->type),
-			addr, ci->handle, ci->state,
-			hci_lmtostr(ci->link_mode));
+			addr, ci->handle, ci->state, str);
+		bt_free(str);
 	}
 
 	return 0;
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools: Fix memory leaks
  2009-02-09 23:50 Gustavo F. Padovan
@ 2009-02-10 15:43 ` Marcel Holtmann
  2009-02-10 17:23   ` Gustavo F. Padovan
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-02-10 15:43 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth

Hi Gustavo,

> Some printfs was using as parameter functions that return dinamic
> allocated memory. Now, we free them!

you patch has been applied, but I had to modify the commit message a lot
to turn it into a little bit more proper English :)

Regards

Marcel



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools: Fix memory leaks
  2009-02-10 15:43 ` Marcel Holtmann
@ 2009-02-10 17:23   ` Gustavo F. Padovan
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo F. Padovan @ 2009-02-10 17:23 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

On Tue, Feb 10, 2009 at 1:43 PM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Gustavo,
>
>> Some printfs was using as parameter functions that return dinamic
>> allocated memory. Now, we free them!
>
> you patch has been applied, but I had to modify the commit message a lot
> to turn it into a little bit more proper English :)

Ok. My English is bad, sorry. ;-)

>
> Regards
>
> Marcel
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



--=20
----------------------------------------------
Gustavo Fernando Padovan
Engenharia de Computa=E7=E3o 2006
Instituto de Computa=E7=E3o - UNICAMP

gfpadovan@gmail.com
gustavo@las.ic.unicamp.br
-------------------------------------------

Seja Livre, use Software Livre

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-10 17:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-09  3:15 [PATCH] tools: Fix memory leaks Gustavo F. Padovan
2009-02-09 12:31 ` Marcel Holtmann
2009-02-09 13:28   ` Gustavo F. Padovan
  -- strict thread matches above, loose matches on Subject: below --
2009-02-09 23:50 Gustavo F. Padovan
2009-02-10 15:43 ` Marcel Holtmann
2009-02-10 17:23   ` Gustavo F. Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox