- Fixes hcitool error code on memory allocations.
PATCH 1/1 - Fixes hcitool error code on memory allocations.
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(-)
Signature · 1 line
Luiz Fernando N. Capitulino
tools/hcitool.c | 72 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 48 insertions(+), 24 deletions(-)
tools/hcitool.c +48 -24
@@ -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 ;
Hi Luiz,
Quoted 7 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel