-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Remove empty state from FixedSpan #29240
Merged
mergify
merged 8 commits into
project-chip:master
from
ksperling-apple:fixed-span-nonempty
Sep 22, 2023
Merged
Remove empty state from FixedSpan #29240
mergify
merged 8 commits into
project-chip:master
from
ksperling-apple:fixed-span-nonempty
Sep 22, 2023
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
github-actions
bot
added
tools
examples
platform
esp32
linux
lib
crypto
controller
app
tests
support
labels
Sep 14, 2023
PR #29240: Size comparison from f47ce53 to 314e759 Increases (43 builds for bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, psoc6, qpg)
Decreases (32 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, esp32, linux, psoc6)
Full report (46 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, psoc6, qpg)
|
ksperling-apple
force-pushed
the
fixed-span-nonempty
branch
from
September 14, 2023 23:17
314e759
to
ac9685c
Compare
PR #29240: Size comparison from d4cbdbc to 53a01ba Increases above 0.2%:
Increases (32 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, k32w, linux, mbed, nrfconnect, psoc6, qpg)
Decreases (32 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, k32w, linux, mbed, nrfconnect, psoc6, qpg)
Full report (32 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, k32w, linux, mbed, nrfconnect, psoc6, qpg)
|
Prior to this change, a default-constructed FixedSpan would be in a state with empty() = true but size() > 0, but nevertheless compare as not equal to an empty non-fixed Span. After this change, a FixedSpan always contains a valid sequence of elements of the relevant size. This aligns the behavior with std::span. The IsSpanUsable() function and the empty() method have been removed because they would always return true, and hence invite programmer errors. Since we still rely on default-constructing certain FixedByteSpan types in a number of places, such instances are now initialized to point to an array of zeroes (the arrays for all sizes of span are shared and limited in size to avoid inadvertently blowing out the constant data size in the binary).
This is validated using VerifyOrDie, but only in code paths that take a raw pointer and size; code paths that take a T[] assume the array is valid and remain unchecked and constexpr.
ksperling-apple
force-pushed
the
fixed-span-nonempty
branch
from
September 17, 2023 23:14
53a01ba
to
af697ed
Compare
PR #29240: Size comparison from 6e3d045 to af697ed Increases above 0.2%:
Increases (65 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
Decreases (13 builds for bl702, bl702l, cc32xx, esp32, linux, psoc6)
Full report (65 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
pullapprove
bot
requested review from
andy31415,
andyg-apple,
anush-apple,
arkq,
bzbarsky-apple and
carol-apple
September 18, 2023 05:05
pullapprove
bot
requested review from
selissia,
sharadb-amazon,
tecimovic,
tima-q,
tobiasgraf,
turon,
vivien-apple,
woody-apple,
younghak-hwang,
yufengwangca and
yunhanw-google
September 18, 2023 05:05
- Fix buffer size check in ConvertECDSASignatureRawToDER - Add deleted nullptr_t overloads to Span and FixedSpan - Comments around constexpr / VerifyOrDie
PR #29240: Size comparison from 6e3d045 to e55e143 Increases above 0.2%:
Increases (65 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
Decreases (9 builds for cc32xx, esp32, linux, psoc6)
Full report (65 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
bzbarsky-apple
approved these changes
Sep 19, 2023
tcarmelveilleux
approved these changes
Sep 19, 2023
PR #29240: Size comparison from 6e3d045 to 72c3f84 Increases above 0.2%:
Increases (38 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg)
Decreases (29 builds for bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, psoc6, qpg)
Full report (38 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg)
|
PR #29240: Size comparison from 6fe4b11 to ae8c4ed Increases above 0.2%:
Increases (66 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
Decreases (8 builds for cc32xx, esp32, linux, psoc6)
Full report (66 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
HunsupJung
pushed a commit
to HunsupJung/connectedhomeip
that referenced
this pull request
Oct 23, 2023
* Remove empty state from FixedSpan Prior to this change, a default-constructed FixedSpan would be in a state with empty() = true but size() > 0, but nevertheless compare as not equal to an empty non-fixed Span. After this change, a FixedSpan always contains a valid sequence of elements of the relevant size. This aligns the behavior with std::span. The IsSpanUsable() function and the empty() method have been removed because they would always return true, and hence invite programmer errors. Since we still rely on default-constructing certain FixedByteSpan types in a number of places, such instances are now initialized to point to an array of zeroes (the arrays for all sizes of span are shared and limited in size to avoid inadvertently blowing out the constant data size in the binary). * Disallow Spans pointing to null if size is not 0 This is validated using VerifyOrDie, but only in code paths that take a raw pointer and size; code paths that take a T[] assume the array is valid and remain unchecked and constexpr. * Deprecate IsSpanUsable(Span) in favor of !empty() * Fix test cases that use invalid ByteSpans * Use ByteSpan() for empty span instead of ByteSpan(nullptr, 0) * Address review comments - Fix buffer size check in ConvertECDSASignatureRawToDER - Add deleted nullptr_t overloads to Span and FixedSpan - Comments around constexpr / VerifyOrDie * Fix project-chip#29326 as per review --------- Co-authored-by: Andrei Litvin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Prior to this change, a default-constructed FixedSpan would be in a state
with empty() = true but size() > 0, and despite being empty compare as not
equal to an empty non-fixed Span.
After this change, a FixedSpan always contains a valid sequence of elements
of the relevant size. This aligns the behavior with std::span.
The IsSpanUsable() function and the empty() method have been removed
because they would always return true, and hence invite programmer errors.
Since we still rely on default-constructing certain FixedByteSpan types in
a number of places, such instances are now initialized to point to an array
of zeroes (the arrays for all sizes of span are shared and limited in size
to avoid inadvertently blowing out the constant data size in the binary).
Also ensure that non-fixed Spans don't point to
nullptr
unlesssize == 0
, anddeprecate IsSpanUsable(Span) in favor of !empty()
This means both types of Spans are always valid in the sense that in-bounds
access is safe. Only non-fixed Spans can be empty.