-
Notifications
You must be signed in to change notification settings - Fork 3k
BLE: Fix SafeEnum type safety #9393
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
Conversation
Fix for one of the issue mentioned here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine - just editing. "Relationnal" misspelled in commit message.
Actually, isn't it still a good idea to put an 'explicit' on the |
48dcd18
to
78c6ac7
Compare
@kjbracey-arm Yes, that's a good idea to mark it as explicit. I don't recall why it wasn't (maybe just a mistake!) and tried it within our codebase and it doesn't yield any error. Going further I marked that constructor as protected as clients do not have any business in constructing SafeEnum outside a derived class. |
78c6ac7
to
f9393e0
Compare
Note: Travis failure is fixed on master (#9391) , if you can rebase to resolve the error |
The relationnal operators were targeting the base class which defines an implicit constructor to an integral value. This is wrong as it allows SafeEnum instances to be compared against integers. The fix is simple: define relationnal operators for the derived class. The derived class is known as it is passed as a template parameter of the base class. For extra safety the SafeEnum constructor is now explicit and protected.
f9393e0
to
79bd3ea
Compare
@0xc0170 done. |
CI started |
Test run: FAILEDSummary: 3 of 7 test jobs failed Failed test jobs:
|
@0xc0170 Examples fixed. Can we relaunch the CI ? |
CI started |
Test run: SUCCESSSummary: 12 of 12 test jobs passed |
Description
The relational operators were targeting the base class which defines an implicit constructor to an integral value. This is wrong as it allows SafeEnum instances to be compared against integers.
The fix is simple: define relationnal operators for the derived class. The derived class is known as it is passed as a template parameter of the base class.
Pull request type
Reviewers
@kjbracey-arm @paul-szczepanek-arm