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

Improve SingletonPtr const correctness #2546

Closed
wants to merge 1 commit into from

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Aug 25, 2016

Make all the functions of SingletonPtr const for improved const
correctness.

Make all the functions of SingletonPtr const for improved const
correctness.
@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 25, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 25, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=GCC_ARM
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

[Build 840]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@pan-
Copy link
Member

pan- commented Aug 25, 2016

I think you have to provide non const overloads as well and makes the return type match the constness:

const T* get() const;
T* get();
const T* operator->() const;
T* operator->();

So users which use a const SingletonPtr<>& will only have access to its const member (data and functions) and user which use a non const version will have access to everything.

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 714

All builds and test passed!

@geky
Copy link
Contributor

geky commented Aug 25, 2016

Out of curiousity, what's the benefit of this over SingletonPtr<const Class>?

@pan-
Copy link
Member

pan- commented Aug 26, 2016

@geky I think people will usually write const SingletonPtr<Class> instead.
The form you write might be used in generic code where at some point SingletonPtr template is instantiated with T = const Class. But in that case, it is never handwritten.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 26, 2016

@pan- I tested locally with the overrides you mention:

const T* get() const;
T* get();
const T* operator->() const;
T* operator->();

There are still compiler errors when I do this and have an object of type const SingletonPtr<Class>. The test I ran was:

const SingletonPtr<std::string> str;

which gave the error "uninitialized const 'str' [-fpermissive]"

Making the class const in the template parameter worked as expected, and get() and ->() operate with the correct constness. I'm closing this PR since it doesn't any value. If you have any suggestions to get const SingletonPtr<Class> working feel free to post here and I'll reopen the PR.

@c1728p9 c1728p9 closed this Aug 26, 2016
@geky
Copy link
Contributor

geky commented Aug 26, 2016

I think having a const-correct SingletonPtr is marginally useful, it is what a user would first expect to do. But not much of a priority.

artokin pushed a commit to artokin/mbed-os that referenced this pull request Jan 18, 2021
…..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
artokin pushed a commit to artokin/mbed-os that referenced this pull request Jan 19, 2021
…15ae9a..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)
35b95da Remove unnecessary files from release
0717432 Merge remote-tracking branch 'origin/release_internal' into release_external
f68126b Adaptation layer MCPS confirmation handle update
e483a07 Added OFDM configurations and FEC in RF config structure (ARMmbed#2513)
b88abfa BUG fix: Fixed broken Brodcast MAC overflow handling
9cad478 Random early detection congestion API update
00aed73 Modified the Wi-SUN stack Latency estimates a bit slower
6b83d82 Remove periodic PAN version increase from Wi-SUN border router
ef670e2 Integrated ReD congestion packet drop to Wi-SUN bootstrap interface.
b956d9e Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbed#2512)
01749c2 Improved transmission in high traffic (ARMmbed#2511)
3158e96 Adaption layer queue trace update
5a32f4a Update changelog, random_early_detection_congestion_check nameupdate and minor comment fix.
b818f12 Extented network status for support dropped tx congestion packet.
11c0763 Added new service Random early detection
f2c358d Optimized medium NWK MPL parameters to 40 second multicast interval (ARMmbed#2508)
c013bc7 Added traces to EAPOL TX failure
c29ee94 Changed TLS return value to int32_t
501a2c8 Added trace for mbed TLS errors
9d7cd22 Updated change log
1290225 Corrected radius message memory allocation
7b1c596 Removed trace print's
efb8393 Adaptation layer MCPS confirmation handle update
ac1025e Bug Fix: Accept only next possible BSI for detect BR reboot and drop unkown's.
58f0e56 Updated change log
102e525 Nanostack now indicates connection down on RPL local repair start
395791d FHSS WS: Do not allow broadcast TX on unicast channel (ARMmbed#2501)
72f8ecb Updated changelog.md
2376208 Activated higher priority by traffic class CS6 for NS/NA and RPL, EAPOL/ DHCP Relay messages.
afbe906 Adaptation layer update
13fb2bf Update CHANGELOG.md
af81c48 DIO init TX filter update
13a872c Fix typos in github template (ARMmbed#2498)
1af20e1 Initial version of CHANGELOG (ARMmbed#2497)
d9874ed Feature update: Improved MAC TX queue purge
6926442 Wi-SUN Aro registration temporary address registation bug fix.
d3170ed Removed generic event and wrong trace info.
0db3486 Removed trace from place which is normal and not needed
a080f18 Added debug tarce for dropped unsecured and MPL packets.
51cd564 Wi-SUN NS probe update:
579f756 Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (ARMmbed#2487)

git-subtree-dir: connectivity/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
artokin pushed a commit to artokin/mbed-os that referenced this pull request Jan 19, 2021
…..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)
35b95da Remove unnecessary files from release
0717432 Merge remote-tracking branch 'origin/release_internal' into release_external
f68126b Adaptation layer MCPS confirmation handle update
e483a07 Added OFDM configurations and FEC in RF config structure (ARMmbed#2513)
b88abfa BUG fix: Fixed broken Brodcast MAC overflow handling
9cad478 Random early detection congestion API update
00aed73 Modified the Wi-SUN stack Latency estimates a bit slower
6b83d82 Remove periodic PAN version increase from Wi-SUN border router
ef670e2 Integrated ReD congestion packet drop to Wi-SUN bootstrap interface.
b956d9e Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbed#2512)
01749c2 Improved transmission in high traffic (ARMmbed#2511)
3158e96 Adaption layer queue trace update
5a32f4a Update changelog, random_early_detection_congestion_check nameupdate and minor comment fix.
b818f12 Extented network status for support dropped tx congestion packet.
11c0763 Added new service Random early detection
f2c358d Optimized medium NWK MPL parameters to 40 second multicast interval (ARMmbed#2508)
c013bc7 Added traces to EAPOL TX failure
c29ee94 Changed TLS return value to int32_t
501a2c8 Added trace for mbed TLS errors
9d7cd22 Updated change log
1290225 Corrected radius message memory allocation
7b1c596 Removed trace print's
efb8393 Adaptation layer MCPS confirmation handle update
ac1025e Bug Fix: Accept only next possible BSI for detect BR reboot and drop unkown's.
58f0e56 Updated change log
102e525 Nanostack now indicates connection down on RPL local repair start
395791d FHSS WS: Do not allow broadcast TX on unicast channel (ARMmbed#2501)
72f8ecb Updated changelog.md
2376208 Activated higher priority by traffic class CS6 for NS/NA and RPL, EAPOL/ DHCP Relay messages.
afbe906 Adaptation layer update
13fb2bf Update CHANGELOG.md
af81c48 DIO init TX filter update
13a872c Fix typos in github template (ARMmbed#2498)
1af20e1 Initial version of CHANGELOG (ARMmbed#2497)
d9874ed Feature update: Improved MAC TX queue purge
6926442 Wi-SUN Aro registration temporary address registation bug fix.
d3170ed Removed generic event and wrong trace info.
0db3486 Removed trace from place which is normal and not needed
a080f18 Added debug tarce for dropped unsecured and MPL packets.
51cd564 Wi-SUN NS probe update:
579f756 Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (ARMmbed#2487)
715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
artokin pushed a commit to artokin/mbed-os that referenced this pull request Jan 21, 2021
…..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)
35b95da Remove unnecessary files from release
0717432 Merge remote-tracking branch 'origin/release_internal' into release_external
f68126b Adaptation layer MCPS confirmation handle update
e483a07 Added OFDM configurations and FEC in RF config structure (ARMmbed#2513)
b88abfa BUG fix: Fixed broken Brodcast MAC overflow handling
9cad478 Random early detection congestion API update
00aed73 Modified the Wi-SUN stack Latency estimates a bit slower
6b83d82 Remove periodic PAN version increase from Wi-SUN border router
ef670e2 Integrated ReD congestion packet drop to Wi-SUN bootstrap interface.
b956d9e Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbed#2512)
01749c2 Improved transmission in high traffic (ARMmbed#2511)
3158e96 Adaption layer queue trace update
5a32f4a Update changelog, random_early_detection_congestion_check nameupdate and minor comment fix.
b818f12 Extented network status for support dropped tx congestion packet.
11c0763 Added new service Random early detection
f2c358d Optimized medium NWK MPL parameters to 40 second multicast interval (ARMmbed#2508)
c013bc7 Added traces to EAPOL TX failure
c29ee94 Changed TLS return value to int32_t
501a2c8 Added trace for mbed TLS errors
9d7cd22 Updated change log
1290225 Corrected radius message memory allocation
7b1c596 Removed trace print's
efb8393 Adaptation layer MCPS confirmation handle update
ac1025e Bug Fix: Accept only next possible BSI for detect BR reboot and drop unkown's.
58f0e56 Updated change log
102e525 Nanostack now indicates connection down on RPL local repair start
395791d FHSS WS: Do not allow broadcast TX on unicast channel (ARMmbed#2501)
72f8ecb Updated changelog.md
2376208 Activated higher priority by traffic class CS6 for NS/NA and RPL, EAPOL/ DHCP Relay messages.
afbe906 Adaptation layer update
13fb2bf Update CHANGELOG.md
af81c48 DIO init TX filter update
13a872c Fix typos in github template (ARMmbed#2498)
1af20e1 Initial version of CHANGELOG (ARMmbed#2497)
d9874ed Feature update: Improved MAC TX queue purge
6926442 Wi-SUN Aro registration temporary address registation bug fix.
d3170ed Removed generic event and wrong trace info.
0db3486 Removed trace from place which is normal and not needed
a080f18 Added debug tarce for dropped unsecured and MPL packets.
51cd564 Wi-SUN NS probe update:
579f756 Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (ARMmbed#2487)
715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants