From: Luiz Fernando Capitulino <lcapitulino@conectiva.com.br>
To: bluez-devel@lists.sourceforge.net, marcel@holtmann.org
Subject: [PATCH] - Fixes hcitool error code on memory allocations.
Date: Thu, 16 Jun 2005 17:18:35 -0300 [thread overview]
Message-ID: <42B1DE9B.5020607@conectiva.com.br> (raw)
[-- 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;
next reply other threads:[~2005-06-16 20:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-16 20:18 Luiz Fernando Capitulino [this message]
2005-06-16 21:26 ` [Bluez-devel] Re: [PATCH] - Fixes hcitool error code on memory allocations Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42B1DE9B.5020607@conectiva.com.br \
--to=lcapitulino@conectiva.com.br \
--cc=bluez-devel@lists.sourceforge.net \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox