From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>
Subject: [PATCH BlueZ 15/17] bccmd: Fix overwriting errno value
Date: Wed, 16 Nov 2011 09:20:02 -0400 [thread overview]
Message-ID: <1321449604-4188-16-git-send-email-anderson.lizardo@openbossa.org> (raw)
In-Reply-To: <1321449604-4188-1-git-send-email-anderson.lizardo@openbossa.org>
On error, transport_read() returns -1 and sets errno.
---
tools/bccmd.c | 32 ++++++++------------------------
1 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/tools/bccmd.c b/tools/bccmd.c
index ca9302c..952bf13 100644
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -253,10 +253,8 @@ static int cmd_builddef(int transport, int argc, char *argv[])
array[1] = def >> 8;
err = transport_read(transport, CSR_VARID_GET_NEXT_BUILDDEF, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
break;
- }
nextdef = array[2] | (array[3] << 8);
@@ -286,10 +284,8 @@ static int cmd_keylen(int transport, int argc, char *argv[])
array[1] = handle >> 8;
err = transport_read(transport, CSR_VARID_CRYPT_KEY_LENGTH, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
handle = array[0] | (array[1] << 8);
keylen = array[2] | (array[3] << 8);
@@ -310,10 +306,8 @@ static int cmd_clock(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_BT_CLOCK, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
clock = array[2] | (array[3] << 8) | (array[0] << 16) | (array[1] << 24);
@@ -333,10 +327,8 @@ static int cmd_rand(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_RAND, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
rand = array[0] | (array[1] << 8);
@@ -357,10 +349,8 @@ static int cmd_chiprev(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_CHIPREV, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
rev = array[0] | (array[1] << 8);
@@ -417,10 +407,8 @@ static int cmd_buildname(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_READ_BUILD_NAME, array, 128);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
for (i = 0; i < sizeof(name); i++)
name[i] = array[(i * 2) + 4];
@@ -441,10 +429,8 @@ static int cmd_panicarg(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_PANIC_ARG, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
error = array[0] | (array[1] << 8);
@@ -465,10 +451,8 @@ static int cmd_faultarg(int transport, int argc, char *argv[])
memset(array, 0, sizeof(array));
err = transport_read(transport, CSR_VARID_FAULT_ARG, array, 8);
- if (err < 0) {
- errno = -err;
+ if (err < 0)
return -1;
- }
error = array[0] | (array[1] << 8);
--
1.7.0.4
next prev parent reply other threads:[~2011-11-16 13:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 13:19 [PATCH BlueZ 00/17] Fix errno handling convention Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 01/17] AVCTP: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 02/17] AVDTP: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 03/17] audio/IPC: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 04/17] audio/PCM: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 05/17] audio: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 06/17] serial: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 07/17] hcitool: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 08/17] hciconfig: " Anderson Lizardo
2011-11-24 5:58 ` Regarding MAP status Jaganath
2011-11-16 13:19 ` [PATCH BlueZ 09/17] textfile: Fix errno handling convention Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 10/17] sdp-client: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 11/17] sap-u8500: " Anderson Lizardo
2011-11-16 13:19 ` [PATCH BlueZ 12/17] network: " Anderson Lizardo
2011-11-16 13:20 ` [PATCH BlueZ 13/17] input: " Anderson Lizardo
2011-11-16 13:20 ` [PATCH BlueZ 14/17] btio: " Anderson Lizardo
2011-11-16 13:20 ` Anderson Lizardo [this message]
2011-11-16 13:20 ` [PATCH BlueZ 16/17] csr_bcsp: Fix missing errno attribution Anderson Lizardo
2011-11-16 13:20 ` [PATCH BlueZ 17/17] Fix return value check for bt_audio_service_open() Anderson Lizardo
2011-11-17 11:58 ` [PATCH BlueZ 00/17] Fix errno handling convention Johan Hedberg
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=1321449604-4188-16-git-send-email-anderson.lizardo@openbossa.org \
--to=anderson.lizardo@openbossa.org \
--cc=linux-bluetooth@vger.kernel.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