Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Matthew, would you review this patch as an owner?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
void* stack = base::span<char>(stack_buf)
.subspan(base::SpanificationSizeofForStdArray(stack_buf))
.data();
This seems very verbose, is there no better way to get a pointer to the "one past the end" of an array?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thank you for the quick review. I addressed the review comment.
void* stack = base::span<char>(stack_buf)
.subspan(base::SpanificationSizeofForStdArray(stack_buf))
.data();
This seems very verbose, is there no better way to get a pointer to the "one past the end" of an array?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
void* stack = base::span<char>(stack_buf)
.subspan(base::SpanificationSizeofForStdArray(stack_buf))
.data();
Yuki ShiinoThis seems very verbose, is there no better way to get a pointer to the "one past the end" of an array?
I introduced a helper function. Does this look fine?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
LGTM
constexpr ElementMaybeConst* SpanificationEndPtrOf(
one past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
constexpr ElementMaybeConst* SpanificationEndPtrOf(
one past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Perhaps if we don't want this, this particular part of the code could be a good candidate for UNSAFE_BUFFERS() and safety comment since there is really no danger of unsafety here, and the pointer addition is pretty clear.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
constexpr ElementMaybeConst* SpanificationEndPtrOf(
Matthew Dentonone past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Perhaps if we don't want this, this particular part of the code could be a good candidate for UNSAFE_BUFFERS() and safety comment since there is really no danger of unsafety here, and the pointer addition is pretty clear.
It could also return a subspan of zero length like the original change was doing, and then we just call data() on that.
Thank you both. Would you take another look?
+R=nuskos@ for owner review of auto_spanification_helper.h.
constexpr ElementMaybeConst* SpanificationEndPtrOf(
Matthew Dentonone past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Matthew DentonPerhaps if we don't want this, this particular part of the code could be a good candidate for UNSAFE_BUFFERS() and safety comment since there is really no danger of unsafety here, and the pointer addition is pretty clear.
It could also return a subspan of zero length like the original change was doing, and then we just call data() on that.
Would you folks take another look?
Taking your advice, I annotated the helper functions with UNSAFE_BUFFER_USAGE (which requires UNSAFE_BUFFERS on call sites), and added UNSAFE_BUFFERS to the call site. PRECONDITION: and SAFETY: comments are added, too.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
constexpr ElementMaybeConst* SpanificationEndPtrOf(
Matthew Dentonone past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Matthew DentonPerhaps if we don't want this, this particular part of the code could be a good candidate for UNSAFE_BUFFERS() and safety comment since there is really no danger of unsafety here, and the pointer addition is pretty clear.
Yuki ShiinoIt could also return a subspan of zero length like the original change was doing, and then we just call data() on that.
Would you folks take another look?
Taking your advice, I annotated the helper functions with UNSAFE_BUFFER_USAGE (which requires UNSAFE_BUFFERS on call sites), and added UNSAFE_BUFFERS to the call site. PRECONDITION: and SAFETY: comments are added, too.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// SpanificationEndPtrOf was introduced temporarily in order to help the auto
If this is temporary what do we expect people to actually write?
```
// Safety: stack is never referenced?
void* stack = UNSAFE_BUFFER(stack_buf.data() + stack_buf.size());
```
I see in the other comment chain @kei...@chromium.org was suggesting another function to make it clear, but then we expect that to be the end result no?
So I think either
1) We keep the function but remove the mention of temporary and perhaps call it EndPtrOf(), then we expect UNSAFE_BUFFER(EndPtrOf(stack_buf)) with a safety promising it won't be referenced.
2) We just keep it as UNSAFE_BUFFER(stack_buf.data() + stack_buf.size()) because that is what we expect long term people to write.
Thoughts? I think we should be consistent and give advice for folks in this scenario.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
The patch became so simple now. Would you take yet another look?
// SpanificationEndPtrOf was introduced temporarily in order to help the auto
If this is temporary what do we expect people to actually write?
```
// Safety: stack is never referenced?
void* stack = UNSAFE_BUFFER(stack_buf.data() + stack_buf.size());
```I see in the other comment chain @kei...@chromium.org was suggesting another function to make it clear, but then we expect that to be the end result no?
So I think either
1) We keep the function but remove the mention of temporary and perhaps call it EndPtrOf(), then we expect UNSAFE_BUFFER(EndPtrOf(stack_buf)) with a safety promising it won't be referenced.
2) We just keep it as UNSAFE_BUFFER(stack_buf.data() + stack_buf.size()) because that is what we expect long term people to write.
Thoughts? I think we should be consistent and give advice for folks in this scenario.
I agree that this will be the end state in this specific case. For other cases, we should encourage the use of iterators instead of raw pointers.
I go with Option 2) UNSAFE_BUFFERS(stack_buf.data() + stack_buf.size()) with a SAFETY: comment.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
// SpanificationEndPtrOf was introduced temporarily in order to help the auto
Yuki ShiinoIf this is temporary what do we expect people to actually write?
```
// Safety: stack is never referenced?
void* stack = UNSAFE_BUFFER(stack_buf.data() + stack_buf.size());
```I see in the other comment chain @kei...@chromium.org was suggesting another function to make it clear, but then we expect that to be the end result no?
So I think either
1) We keep the function but remove the mention of temporary and perhaps call it EndPtrOf(), then we expect UNSAFE_BUFFER(EndPtrOf(stack_buf)) with a safety promising it won't be referenced.
2) We just keep it as UNSAFE_BUFFER(stack_buf.data() + stack_buf.size()) because that is what we expect long term people to write.
Thoughts? I think we should be consistent and give advice for folks in this scenario.
I agree that this will be the end state in this specific case. For other cases, we should encourage the use of iterators instead of raw pointers.
I go with Option 2) UNSAFE_BUFFERS(stack_buf.data() + stack_buf.size()) with a SAFETY: comment.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +2 |
constexpr ElementMaybeConst* SpanificationEndPtrOf(
Matthew Dentonone past the end pointers are scary so it would be nice to have a helper function to make them stand out.
Matthew DentonPerhaps if we don't want this, this particular part of the code could be a good candidate for UNSAFE_BUFFERS() and safety comment since there is really no danger of unsafety here, and the pointer addition is pretty clear.
Yuki ShiinoIt could also return a subspan of zero length like the original change was doing, and then we just call data() on that.
Matthew DentonWould you folks take another look?
Taking your advice, I annotated the helper functions with UNSAFE_BUFFER_USAGE (which requires UNSAFE_BUFFERS on call sites), and added UNSAFE_BUFFERS to the call site. PRECONDITION: and SAFETY: comments are added, too.
Thanks, still +1
Done
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
spanification: automatically spanify sandbox/linux/services/credentials.cc
This is the result of running the automatic spanification on linux and
updating code to use and pass spans where size is known.
The original patch was fully automated using script:
//tools/clang/spanify/rewrite-multiple-platforms.sh -platforms=linux
Then refined with gemini-cli
gemini-run/batch-run-1755453491/group_100
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |