Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] - Fixes hcitool error code on memory allocations.
@ 2005-06-16 20:18 Luiz Fernando Capitulino
  2005-06-16 21:26 ` [Bluez-devel] " Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Fernando Capitulino @ 2005-06-16 20:18 UTC (permalink / raw)
  To: bluez-devel, marcel

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

Hello all,

This patch adds proper error code and message for memory allocations
errors in hcitool program.

Comments are welcome.

tools/hcitool.c |   72 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 48 insertions(+), 24 deletions(-)

-- 
Luiz Fernando N. Capitulino

[-- Attachment #2: hcitool_malloc_audit.patch --]
[-- Type: text/x-patch, Size: 3607 bytes --]

 tools/hcitool.c |   72 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 24 deletions(-)


diff -X /home/lcapitulino/kernels/2.6/dontdiff -Nparu a/tools/hcitool.c a~/tools/hcitool.c
--- a/tools/hcitool.c	2005-05-09 15:33:24.000000000 -0300
+++ a~/tools/hcitool.c	2005-06-12 20:30:11.000000000 -0300
@@ -1030,8 +1030,10 @@ static void cmd_dc(int dev_id, int argc,
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1165,8 +1167,10 @@ static void cmd_rssi(int dev_id, int arg
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1236,8 +1240,10 @@ static void cmd_lq(int dev_id, int argc,
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1309,8 +1315,10 @@ static void cmd_tpl(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1382,8 +1390,10 @@ static void cmd_afh(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1465,8 +1475,10 @@ static void cmd_cpt(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1546,8 +1558,10 @@ static void cmd_lst(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1631,8 +1645,10 @@ static void cmd_auth(int dev_id, int arg
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1700,8 +1716,10 @@ static void cmd_enc(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1770,8 +1788,10 @@ static void cmd_key(int dev_id, int argc
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1839,8 +1859,10 @@ static void cmd_clkoff(int dev_id, int a
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;
@@ -1912,8 +1934,10 @@ static void cmd_clock(int dev_id, int ar
 	}
 
 	cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
-	if (!cr)
-		return;
+	if (!cr) {
+		perror("Can't allocate memory");
+		exit(1);
+	}
 
 	bacpy(&cr->bdaddr, &bdaddr);
 	cr->type = ACL_LINK;

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

* [Bluez-devel] Re: [PATCH] - Fixes hcitool error code on memory allocations.
  2005-06-16 20:18 [PATCH] - Fixes hcitool error code on memory allocations Luiz Fernando Capitulino
@ 2005-06-16 21:26 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2005-06-16 21:26 UTC (permalink / raw)
  To: Luiz Fernando Capitulino; +Cc: bluez-devel

Hi Luiz,

> This patch adds proper error code and message for memory allocations
> errors in hcitool program.
> 
> Comments are welcome.
> 
> tools/hcitool.c |   72 +++++++++++++++++++++++++++++++++++++-------------------
> 1 files changed, 48 insertions(+), 24 deletions(-)

applied. Thanks.

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

end of thread, other threads:[~2005-06-16 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 20:18 [PATCH] - Fixes hcitool error code on memory allocations Luiz Fernando Capitulino
2005-06-16 21:26 ` [Bluez-devel] " Marcel Holtmann

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