Fix format warning for st_size base type linux vs mac#35
Fix format warning for st_size base type linux vs mac#35TheOneRing wants to merge 2 commits intomainfrom
Conversation
Also check buffer size
There was a problem hiding this comment.
Pull request overview
This PR updates the FUSE getxattr implementation to avoid st_size printf-format warnings across Linux/macOS and adds buffer-size checking when returning the user.openvfs.realsize extended attribute.
Changes:
- Replace
snprintf("%lld", statbuf.st_size)withstd::to_string(statbuf.st_size)and manual copying to the caller-provided buffer. - Switch default attribute copying from
std::copy(begin/end, ...)tostd::ranges::copy(...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return -errno; | ||
| } | ||
| return std::snprintf(value, size, "%lld", statbuf.st_size); | ||
| const auto realSize = std::to_string(statbuf.st_size); |
There was a problem hiding this comment.
Maybe add a comment so that we still remember in two weeks, something like
if the incoming size is zero, the system call getxattr returns the size of the buffer to store the
value in. Check the manpage of getxattr.
The extra way through std::string fixes cross platform warnings about different size types on
Mac vs Linux.
Also check buffer size