Skip to content

ptfs: use BorrowedFd instead of RawFd when possible#173

Merged
eryugey merged 1 commit intocloud-hypervisor:masterfrom
jiangliu:borrowed-fd
Nov 14, 2023
Merged

ptfs: use BorrowedFd instead of RawFd when possible#173
eryugey merged 1 commit intocloud-hypervisor:masterfrom
jiangliu:borrowed-fd

Conversation

@jiangliu
Copy link
Contributor

@jiangliu jiangliu commented Nov 6, 2023

Use BorrowedFd instead of RawFd when possible.

@@ -272,8 +282,8 @@ impl HandleData {
// object is within scope. Otherwise it may cause race window to access wrong target fd.
// By introducing this method, we could explicitly audit all callers making use of the
// underlying RawFd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments above are still referencing RawFd, these should be updated as well?

Also, it'd be better to describe why we're replacing RawFd with BorrowedFd in commit log, what are the benefits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Use BorrowedFd instead of RawFd when possible. By using BorrowedFd
we can explicitly manage the lifetime of the underlying RawFd,
to avoid misusing after file close.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
@eryugey eryugey merged commit cc0a191 into cloud-hypervisor:master Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants