Skip to content

Fix format warning for st_size base type linux vs mac#35

Open
TheOneRing wants to merge 2 commits intomainfrom
work/buf
Open

Fix format warning for st_size base type linux vs mac#35
TheOneRing wants to merge 2 commits intomainfrom
work/buf

Conversation

@TheOneRing
Copy link
Collaborator

Also check buffer size

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with std::to_string(statbuf.st_size) and manual copying to the caller-provided buffer.
  • Switch default attribute copying from std::copy(begin/end, ...) to std::ranges::copy(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

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.

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.

3 participants