Skip to content

Simplified dispatcher, removed duplicate code, fixed regression #956#958

Merged
uweseimet merged 2 commits intodevelopfrom
feature-dispatcher-using-lambdas
Nov 2, 2022
Merged

Simplified dispatcher, removed duplicate code, fixed regression #956#958
uweseimet merged 2 commits intodevelopfrom
feature-dispatcher-using-lambdas

Conversation

@uweseimet
Copy link
Copy Markdown
Contributor

@uweseimet uweseimet commented Nov 2, 2022

Most important changes:

@uweseimet uweseimet changed the title Simplified dispatcher with lambdas, removed duplicate code, cleanup Simplified dispatcher, removed duplicate code, fixed regression #956 Nov 2, 2022
@uweseimet uweseimet marked this pull request as ready for review November 2, 2022 07:25
//---------------------------------------------------------------------------
int BUS::GetCommandByteCount(uint8_t opcode)
{
if (opcode == 0x88 || opcode == 0x8A || opcode == 0x8F || opcode == 0x91 || opcode == 0x9E || opcode == 0x9F) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change these to enum values from scsi.h?

ex: eCmdRead16 = 0x88,

Copy link
Copy Markdown
Contributor Author

@uweseimet uweseimet Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@akuker akuker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment. Thank you!

I'll approve anyway, so feel free to merge whenever.

@uweseimet
Copy link
Copy Markdown
Contributor Author

@akuker Thank you. I just commented on your change request and guess this is OK for you.

@uweseimet uweseimet merged commit c41373d into develop Nov 2, 2022
@uweseimet uweseimet deleted the feature-dispatcher-using-lambdas branch November 2, 2022 14:36
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Nov 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

93.0% 93.0% Coverage
0.0% 0.0% Duplication

uweseimet added a commit that referenced this pull request Nov 2, 2022
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initializing a disk with HD SC Setup no longer works Use lambdas to simplify dispatching commands

2 participants