-
Notifications
You must be signed in to change notification settings - Fork 516
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
const correctness for platform write #121
Comments
As noted in zephyrproject-rtos/zephyr#34389 this would also apply to the |
Yes, that's correct. I confirm that it would be nice to add the 'const' to the fields. I already discussed internally, and if that would be changed in the STdC drivers I will align them in zephyr and would be able to remove the bad casting I had to insert when using the ctx handle. |
Some development efforts have a policy that when a function promises not to modify data referenced by pointer, the referenced data should have a
const
qualifier in the function parameter declaration.In that situation the declaration for
stmdev_write_ptr
may force the caller to cast away const to satisfy the current signature:This casting would not be necessary if the signature were instead:
It doesn't seem reasonable to expect any platform write implementation to be allowed to change data that it is transferring to the device, so tightening the declaration should be technically OK. But since the change would affect every existing platform_write implementation it would break existing code, so should probably be part of an update to version 2.x.
Just something to keep in mind.
The text was updated successfully, but these errors were encountered: