Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPP&OCPP201: explicitly handle all cases in switch statements #880

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

hikinggrass
Copy link
Contributor

Remove default: statements, turn on compiler error on enum conversion switch-case statements. This ensures that all cases are explicitly handled. This should also ensure that throw statements in the conversions functions are never be reached, they remain to prevent "control reaches end of non-void function" compiler warnings

Describe your changes

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

Copy link
Contributor

@maaikez maaikez left a comment

Choose a reason for hiding this comment

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

Good idea! Looks good.

@barsnick
Copy link
Contributor

Good idea! Looks good.

Same. We should do the same for all code, in the long run.

BTW, it also protects against changes in the enum declarations and missing them in some handling functions.

@corneliusclaussen corneliusclaussen added the include-in-release Tag that this PR should be included in the current merge window for the upcoming release if possible label Oct 1, 2024
Remove default: statements, turn on compiler error on enum conversion switch-case statements. This ensures that all cases are explicitly handled.
This should also ensure that throw statements in the conversions functions are never be reached, they remain to prevent "control reaches end of non-void function" compiler warnings

Signed-off-by: Kai-Uwe Hermann <[email protected]>
@corneliusclaussen corneliusclaussen force-pushed the feature/ocpp-non-throwing-enum-conversions branch from f42780c to 94bf654 Compare October 2, 2024 08:27
@corneliusclaussen corneliusclaussen merged commit f19861c into main Oct 2, 2024
10 checks passed
@corneliusclaussen corneliusclaussen deleted the feature/ocpp-non-throwing-enum-conversions branch October 2, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include-in-release Tag that this PR should be included in the current merge window for the upcoming release if possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants