-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/net/sock_udp: Add missing const
qualifier
#20863
Conversation
The APIs `sock_udp_get_local()` and `sock_udp_get_remote()` are expected to be simple getters that do not modify the socket in any way. Hence, the should use `cost sock_udp_t *` rather than `sock_udp_t *` as first argument. This fixes the issue.
08cc31e
to
a74c7df
Compare
Are you sure that a change (even if small) to a major front-facing API can be classified as "minor impact"? |
Also: why only change |
Yes, as C callers will not be affected. (Converting a
I can take a look if similar issues are there as well. But let's fix one bug at a time. |
To me its the same API, so IMHO it should be fixed in one go... But |
For TCP making the I'm closing this for now. |
Revisiting this: I believe it is justified to have the TCP socket write-able: The connection sockets are not owned by the user of the API, but by the listen/queue socket that will freely reuse them when new connections get accepted. The mutex does only solve a data race, though: E.g. code may still assume that a socket is still belonging to connection A when it is calling For UDP, the story is different. A user of the API will create the socket, and it can be assumed that the endpoint will not be changed while the caller is still owning the socket. I assume the same to be true for DTLS. I suggest that I change the parameter to |
Contribution description
The APIs
sock_udp_get_local()
andsock_udp_get_remote()
are expected to be simple getters that do not modify the socket in any way. Hence, the should usecost sock_udp_t *
rather thansock_udp_t *
as first argument.This fixes the issue.
Note: Since C callers will not be affected by this change, I will not add the API change label.
Testing procedure
The CI should be green.
Issues/PRs references
None