benign const qualifiers in inline functions
<!-- Kamailio Pull Request Template -->
<!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [x] Commit message has the format required by CONTRIBUTING guide - [x] Commits are split per component (core, individual modules, libs, utils, ...) - [x] Each component has a single commit (if not, squash them into one commit) - [x] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [x] Small bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [x] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description <!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3120
-- Commit Summary --
* core: const correctness
-- File Changes --
M src/core/ip_addr.h (12)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3120.patch https://github.com/kamailio/kamailio/pull/3120.diff
Can you provide more details why these changes are useful or necessary?
Its about const correctness, which is a good idea especially for API or core Code. https://isocpp.org/wiki/faq/const-correctness#overview-const ________________________________ From: sr-dev sr-dev-bounces@lists.kamailio.org on behalf of Daniel-Constantin Mierla notifications@github.com Sent: Friday, May 20, 2022 2:32:08 PM To: Kamailio Devel List sr-dev@lists.sip-router.org Cc: Subscribed subscribed@noreply.github.com Subject: Re: [sr-dev] [kamailio/kamailio] core: const correctness (PR #3120)
Can you provide more details why these changes are useful or necessary?
— Reply to this email directly, view it on GitHubhttps://github.com/kamailio/kamailio/pull/3120#issuecomment-1132793374, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABO7UZJKY2X7JLIBRM466J3VK5Z3RANCNFSM5WPA2VNA. You are receiving this because you are subscribed to this thread.Message ID: kamailio/kamailio/pull/3120/c1132793374@github.com
They are not necessary. In fact, I needed const only in `init_dst_from_rcv` for an internal module, but, with the occasion, I added more const for consistency - including existing code like `su_cmp` and `su_getport`. So, apart from consistency and style, they are neither useful for the community, I guess.
I think they are useful. I have done several changes like this in the past. It allows the Compiler to optimize better and will also prevent unintended modifications which can lead to bugs ________________________________ From: sr-dev sr-dev-bounces@lists.kamailio.org on behalf of liviu-rolo notifications@github.com Sent: Friday, May 20, 2022 2:57:59 PM To: Kamailio Devel List sr-dev@lists.sip-router.org Cc: Subscribed subscribed@noreply.github.com Subject: Re: [sr-dev] [kamailio/kamailio] core: const correctness (PR #3120)
They are not necessary. In fact, I needed const only in init_dst_from_rcv for an internal module, but, with the occasion, I added more const for consistency - including existing code like su_cmp and su_getport. So, apart from consistency and style, they are neither useful for the community, I guess.
— Reply to this email directly, view it on GitHubhttps://github.com/kamailio/kamailio/pull/3120#issuecomment-1132815693, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABO7UZL2DCGGMJHPOZ654JDVK544PANCNFSM5WPA2VNA. You are receiving this because you are subscribed to this thread.Message ID: kamailio/kamailio/pull/3120/c1132815693@github.com
Merged #3120 into master.
@henningw - to my knowledge, there is no optimisation that a compiler can do to const parameters of a function.
I asked because the most of the functions there were not touched for ages, so not usual suspects for unintended changes.
Moreover, the commit message is somehow contradictory, first lines suggests is makes something correct (like it was wrong before), but then in the second line says the changes are benign.
But if people thinks it is better aesthetic this way, then ok.
Thanks @miconda - you are right the commit message is a bit misleading, I've missed that, my fault.
Sorry for the mentioned problems. To my defense: * "const correctness" is a C++ term with a wrong name: not using const is not "incorrect" by no means * I am a "greenhorn" in open source & this project, somehow bored of just asking questions * Thank you