Skip to contentSkip to conversation

shared/att: Fix responding to unknown command opcode

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Apr 26, 2017 – Apr 27, 2017 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 shared/att: Fix responding to unknown command opcode

From: Luiz Augusto von Dentz <[email protected]>

In case of receiving an unknown command no response shall be generated.

---
 src/shared/att.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/att.c +1 -1
index 3071b51..10e182f 100644
@@ -148,7 +148,7 @@ static enum att_op_type get_op_type(uint8_t opcode)
 			return att_opcode_type_table[i].type;
 	}
 
-	return ATT_OP_TYPE_UNKNOWN;
+	return opcode & ATT_OP_CMD_MASK ? ATT_OP_TYPE_CMD : ATT_OP_TYPE_UNKNOWN;
 }
 
 static const struct {
Signature · 1 line
2.9.3
maintainer
#1 lore raw

Hi Luiz,

Quoted 10 lines

In case of receiving an unknown command no response shall be generated.
---
src/shared/att.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/att.c +0 -0
index 3071b51..10e182f 100644

src/shared/att.c static enum att_op_type get_op_type(uint8_t opcode) · line 152

Quoted 6 lines
src/shared/att.c +1 -1
@@ -148,7 +148,7 @@ static enum att_op_type get_op_type(uint8_t opcode)
 			return att_opcode_type_table[i].type;
 	}
 
-	return ATT_OP_TYPE_UNKNOWN;
+	return opcode & ATT_OP_CMD_MASK ? ATT_OP_TYPE_CMD : ATT_OP_TYPE_UNKNOWN;
 }

for readability I would use this:

	return (opcode & ATT_OP_CMD_MASK) ? ATT_OP_TYPE_CMD : ATT_OP_TYPE_UNKNOWN;

Or just do this:

	if (opcode & ATT_OP_CMD_MASK)
		return ATT_OP_TYPE_CMD;

	return ATT_OP_TYPE_UNKNOWN;

Regards

Marcel

author maintainer
#2 lore raw

Hi Marcel,

Quoted 21 lines · Marcel Holtmann

Hi Luiz,

Quoted 10 lines

In case of receiving an unknown command no response shall be generated.
---
src/shared/att.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/att.c +0 -0
index 3071b51..10e182f 100644

src/shared/att.c static enum att_op_type get_op_type(uint8_t opcode) · line 152

Quoted 6 lines
src/shared/att.c +1 -1
@@ -148,7 +148,7 @@ static enum att_op_type get_op_type(uint8_t opcode)
                      return att_opcode_type_table[i].type;
      }
 
-     return ATT_OP_TYPE_UNKNOWN;
+     return opcode & ATT_OP_CMD_MASK ? ATT_OP_TYPE_CMD : ATT_OP_TYPE_UNKNOWN;
 }

for readability I would use this:

Quoted 8 lines
        return (opcode & ATT_OP_CMD_MASK) ? ATT_OP_TYPE_CMD : ATT_OP_TYPE_UNKNOWN;

Or just do this:

        if (opcode & ATT_OP_CMD_MASK)
                return ATT_OP_TYPE_CMD;

        return ATT_OP_TYPE_UNKNOWN;

Ive made these modifications above and applied the patch.

Quoted 4 lines

Regards

Marcel

Signature · 1 line
Luiz Augusto von Dentz