shared/att: Fix responding to unknown command opcode
Luiz Augusto von Dentz
maintainerPATCH 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
@@ -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
Marcel Holtmann
maintainerHi 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
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
Luiz Augusto von Dentz
maintainerHi 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
-0src/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