Simplified dispatcher, removed duplicate code, fixed regression #956#958
Simplified dispatcher, removed duplicate code, fixed regression #956#958
Conversation
| //--------------------------------------------------------------------------- | ||
| int BUS::GetCommandByteCount(uint8_t opcode) | ||
| { | ||
| if (opcode == 0x88 || opcode == 0x8A || opcode == 0x8F || opcode == 0x91 || opcode == 0x9E || opcode == 0x9F) { |
There was a problem hiding this comment.
Can we change these to enum values from scsi.h?
ex: eCmdRead16 = 0x88,
There was a problem hiding this comment.
Yes and no ;-). I intend to change this anyway, by extending the new scsi_command_map (in scsi.h) with the byte count for each command. The more commands are implemented, the more opcode comparisons we would need otherwise, and some of the newer opcodes are quite different regarding their byte count.
If we were changing this to enum values now we would get kind of an issue here:
} else if (opcode >= 0x20 && opcode <= 0x7D) {
There are no enum values for 0x20 and 0x7d, and if we use the existing ones the logic would change or we would have to introduce dummy enum values for 0x20 and 0x7d.
Would you agree to wait until we have the improved mapping (with the byte count)? Then the code snippet above will become obsolete anyway.
akuker
left a comment
There was a problem hiding this comment.
One minor comment. Thank you!
I'll approve anyway, so feel free to merge whenever.
|
@akuker Thank you. I just commented on your change request and guess this is OK for you. |
|
Kudos, SonarCloud Quality Gate passed! |
commit c41373d Author: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Wed Nov 2 15:36:19 2022 +0100 Use lambdas for dispatcher, code cleanup, test updates (#958) * Using lambdas instead of member function pointers simplifies the command dispatching and reduces the code volume * Removed duplicate error handling * Fix for issue #956 * Unit test updates * Resolved SonarQube issues commit 31dd063 Author: akuker <34318535+akuker@users.noreply.github.com> Date: Wed Nov 2 08:58:59 2022 -0500 Create devices after bus creation (#954)








Most important changes: