[libc-commits] [libc] [libc] implement pathconf/fpathconf (PR #87165)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Mon May 13 06:58:13 PDT 2024
================
@@ -101,18 +101,19 @@ static long fpathconfig(const struct fstatfs &s, int name) {
case _PC_REC_MAX_XFER_SIZE:
case _PC_SYMLINK_MAX:
case _PC_SYNC_IO:
+ return -1;
+
default:
+ errno = EINVAL;
return -1;
}
}
LLVM_LIBC_FUNCTION(long, fpathconf, (int fd, int name)) {
struct fstatfs sb;
- cpp::optional<LinuxStatFs> result = linux_fstatfs(fd);
- if (!result.has_value()) {
- return -1;
- }
- return fpathconfig(sb, name);
+ if (cpp::optional<LinuxStatFs> result = linux_fstatfs(fd))
+ return fpathconfig(sb, name);
----------------
SchrodingerZhu wrote:
I think this function is wrongly implemented and it depends on an uninitialized variable.
```c++
static long pathconfig(const struct statfs &s, int name);
```
Given that this function is repeatedly used in these two files, would you mind separate them into a header library?
https://github.com/llvm/llvm-project/pull/87165
More information about the libc-commits
mailing list