Skip to content

Commit 61cb136

Browse files
comment about pattern filling
1 parent 51253fc commit 61cb136

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

libc/src/sys/statvfs/linux/statfs_utils.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ using LinuxStatFs = statfs;
2626
#endif
2727

2828
LIBC_INLINE cpp::optional<LinuxStatFs> linux_statfs(const char *path) {
29-
#ifdef __clang__
30-
// Disable pattern filling for result buffer: this struct is to be populated
31-
// by the syscall.
32-
[[clang::uninitialized]]
33-
#endif
29+
// The kernel syscall routine checks the validity of the path before filling
30+
// the statfs structure. So, it is possible that the result is not initialized
31+
// after the syscall. Since the struct is trvial, the compiler will generate
32+
// pattern filling for the struct.
3433
LinuxStatFs result;
3534
// On 32-bit platforms, original statfs cannot handle large file systems.
3635
// In such cases, SYS_statfs64 is defined and should be used.
@@ -47,6 +46,10 @@ LIBC_INLINE cpp::optional<LinuxStatFs> linux_statfs(const char *path) {
4746
}
4847

4948
LIBC_INLINE cpp::optional<LinuxStatFs> linux_fstatfs(int fd) {
49+
// The kernel syscall routine checks the validity of the path before filling
50+
// the statfs structure. So, it is possible that the result is not initialized
51+
// after the syscall. Since the struct is trvial, the compiler will generate
52+
// pattern filling for the struct.
5053
LinuxStatFs result;
5154
// On 32-bit platforms, original fstatfs cannot handle large file systems.
5255
// In such cases, SYS_fstatfs64 is defined and should be used.

0 commit comments

Comments
 (0)