[PATCH BlueZ 15/17] bccmd: Fix overwriting errno value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux