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
[type-traits] add 'IsPointer<Type>' and use it in message/dataset #5735
Merged
jwhui
merged 1 commit into
openthread:master
from
abtink:type-trait/add-and-use-in-templates
Oct 29, 2020
Merged
[type-traits] add 'IsPointer<Type>' and use it in message/dataset #5735
jwhui
merged 1 commit into
openthread:master
from
abtink:type-trait/add-and-use-in-templates
Oct 29, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Report of OpenThread
|
Codecov Report
@@ Coverage Diff @@
## master #5735 +/- ##
==========================================
- Coverage 82.76% 82.74% -0.03%
==========================================
Files 377 377
Lines 48396 48396
==========================================
- Hits 40057 40045 -12
- Misses 8339 8351 +12
|
Irving-cl
approved these changes
Oct 29, 2020
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.
LGTM.
This commit adds a new header `common/type_traits.hpp` which provides `IsPointer<Type>` to check whether a template `Type` is a pointer type or not. This is then used in `Message` and `Dataset` methods where we append/set a generic object to check (as an `static_assert`) that the object type is not a pointer. This adds protection (causing a compile time error) against potential incorrect use of these methods (i.e., passing a pointer instead of a reference to an object by mistake).
abtink
force-pushed
the
type-trait/add-and-use-in-templates
branch
from
October 29, 2020 00:40
b98c1c5
to
5067f4a
Compare
jwhui
approved these changes
Oct 29, 2020
simonlingoogle
pushed a commit
to simonlingoogle/openthread
that referenced
this pull request
Nov 12, 2020
Bug: 171933690 * origin/github/master: [low-power] implement forward tracking series (openthread#5608) [efr32] radio: increase FIFO size to allow handling of heavy traffic (openthread#5742) [test] verify realm-local multicast on POSIX (openthread#5738) [clang-tidy] google-explicit-constructor (openthread#5734) [clang-tidy] misc-unused-using-decls (openthread#5732) [continuous-integration] use lcov to generate coverage data (openthread#5635) [type-traits] add 'IsPointer<Type>' and use it in message/dataset (openthread#5735) [posix] set default IPv6 hop limit to OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT (openthread#5736) [net-diag] invoke the callback when failed to get the response (openthread#5653) [site] fix border router guide typo in network (openthread#5731) [cli] update cli doc (openthread#5729) [thread-cert] refactor case 5.1.3 using pktverify (openthread#5708) [thread-cert] refactor case 5.1.2 using pktverify (openthread#5686) [test] arm build with cmake 3.10 (openthread#5727) [clang-tidy] google-readability-casting (openthread#5720) [clang-tidy] modernize-use-equals-default (openthread#5719) [clang-tidy] readability-avoid-const-params-in-decls (openthread#5717) [clang-tidy] modernize-use-equals-delete (openthread#5718) [efr32] add MG21/BRD4180B support (openthread#5725) [posix] fix cast-align build error on ARM (openthread#5672) [logging] add optional `otPlatLogLine()` & use it in NCP/CLI (openthread#5704) [clang-tidy] readability-simplify-boolean-expr (openthread#5716) [clang-tidy] modernize-use-nullptr (openthread#5715) [dataset] add new helper 'SetTlv()' with a template 'ValueType' (openthread#5722) [dataset-manager] simplify 'SendSetRequest()' (openthread#5721) [nrf528xx] fix SPI issue (openthread#5703) [clang-tidy] modernize-use-bool-literals (openthread#5714) [cmake] no target_link_options in cmake 3.10 (openthread#5706) [low-power] enhance CSL transmission on NRF52840 using `transmit_at` (openthread#5545) [build] fix warning of clearing non-trivial type (openthread#5710) [scripts] add MLR Backbone multicast routing test (openthread#5578) [mlr] fix build when OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE is disabled (openthread#5711) [cmake] use init flags in toolchain files (openthread#5705) [cmake] set default build type to Debug (openthread#5709) [thread-cert] refactor case 5.1.1 using pktverify (openthread#5680) [posix] fix udp close (openthread#5690) Change-Id: Ic7e4051040f093aa6dce9de5e2031a8accddec87
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds a new header
common/type_traits.hpp
which providesIsPointer<Type>
to check whether a templateType
is a pointer typeor not. This is then used in
Message
andDataset
methods where weappend/set a generic object to check (as an
static_assert
) that theobject type is not a pointer. This adds protection (causing a compile
time error) against potential incorrect use of these methods (i.e.,
passing a pointer instead of a reference to an object by mistake).