[libc-commits] [libc] [libc] add statvfs/fstatvfs (PR #86169)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Mar 25 09:36:04 PDT 2024
================
@@ -14,11 +14,10 @@ namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, fstatvfs, (int fd, struct statvfs *buf)) {
using namespace statfs_utils;
- if (cpp::optional<LinuxStatFs> result = linux_fstatfs(fd)) {
- *buf = statfs_to_statvfs(*result);
- return 0;
- }
- return -1;
+ cpp::optional<LinuxStatFs> result = linux_fstatfs(fd);
+ if (result)
+ statfs_to_statvfs(*result, *buf);
----------------
nickdesaulniers wrote:
Seeing pointers from userspace get immediately converted to references is a great way to wind up with UB.
These interfaces in particular are ones I hope to address with: https://github.com/llvm/llvm-project/issues/86527
Do you mind adding `LIBC_ASSERT`s here and for `statvfs` below?
https://github.com/llvm/llvm-project/pull/86169
More information about the libc-commits
mailing list