Skip to content

[scudo] Clean the TODO in list.h #119323

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

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions compiler-rt/lib/scudo/standalone/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ class LinkOp {

template <class T> class LinkOp<T, /*LinkWithPtr=*/false> {
public:
using LinkTy = decltype(T::Next);
using LinkTy = typename assertSameType<
typename removeConst<decltype(T::Next)>::type,
typename removeConst<decltype(T::EndOfListVal)>::type>::type;

LinkOp() = default;
// TODO: Check if the `BaseSize` can fit in `Size`.
LinkOp(T *BaseT, uptr BaseSize)
: Base(BaseT), Size(static_cast<LinkTy>(BaseSize)) {}
void init(T *LinkBase, uptr BaseSize) {
Expand All @@ -70,11 +71,12 @@ template <class T> class LinkOp<T, /*LinkWithPtr=*/false> {
}
// Set `X->Next` to `Next`.
void setNext(T *X, T *Next) const {
// TODO: Check if the offset fits in the size of `LinkTy`.
if (Next == nullptr)
if (Next == nullptr) {
X->Next = getEndOfListVal();
else
} else {
DCHECK_LE(static_cast<LinkTy>(Next - Base), Size);
X->Next = static_cast<LinkTy>(Next - Base);
}
}

T *getPrev(T *X) const {
Expand All @@ -94,7 +96,6 @@ template <class T> class LinkOp<T, /*LinkWithPtr=*/false> {
X->Prev = static_cast<LinkTy>(Prev - Base);
}

// TODO: `LinkTy` should be the same as decltype(T::EndOfListVal).
LinkTy getEndOfListVal() const { return T::EndOfListVal; }

protected:
Expand Down
Loading