Skip to contentSkip to conversation

emulator: Fix condition check in btdev_create()

PATCH Applied Inga Stotland 2 participants 2 messages Jul 4, 2019 – Jul 12, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 emulator: Fix condition check in btdev_create()

This fixes a case where logical '||' was used with constant operand and the condition check always resulted in true.

Was: if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE

                                        || BTDEV_TYPE_BREDRLE50)
Fixed: if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE
                                        || type == BTDEV_TYPE_BREDRLE50)
---
 emulator/btdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
emulator/btdev.c +1 -1
index f4c79c2d0..38d5b3b1f 100644
@@ -645,7 +645,7 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id)
 	memset(btdev, 0, sizeof(*btdev));
 
 	if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE
-				|| BTDEV_TYPE_BREDRLE50) {
+				|| type == BTDEV_TYPE_BREDRLE50) {
 		btdev->crypto = bt_crypto_new();
 		if (!btdev->crypto) {
 			free(btdev);
Signature · 1 line
2.21.0
Applied
#1 lore raw

Applied.

Quoted 26 lines · Inga Stotland

This fixes a case where logical '||' was used with constant operand and the condition check always resulted in true.

Was: if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE

                                        || BTDEV_TYPE_BREDRLE50)
Fixed: if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE
                                        || type ==
BTDEV_TYPE_BREDRLE50)
---
 emulator/btdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
emulator/btdev.c +1 -1
index f4c79c2d0..38d5b3b1f 100644
@@ -645,7 +645,7 @@ struct btdev *btdev_create(enum btdev_type type,
 uint16_t id)
 	memset(btdev, 0, sizeof(*btdev));
 
 	if (type == BTDEV_TYPE_BREDRLE || type == BTDEV_TYPE_LE
-				|| BTDEV_TYPE_BREDRLE50) {
+				|| type == BTDEV_TYPE_BREDRLE50) {
 		btdev->crypto = bt_crypto_new();
 		if (!btdev->crypto) {

free(btdev);