Skip to content

Haiku, incorrect pointer type on statvfs #14607

Description

@kallisti5

Haiku uses a i64 for pointers within statvfs. I was working on patches to support Haiku and ran across this:

    fn free_blocks(&self) -> u64 {
        #[cfg(target_pointer_width = "64")]
        return self.f_bfree;
        #[cfg(not(target_pointer_width = "64"))]
        return self.f_bfree.into();
    }

This works for u64 vs not u64, however haiku uses i64 which means this code fails to compile.

I worked up a fix to address this... however it is pretty ugly:

    fn total_blocks(&self) -> u64 {
        #[cfg(all(
            target_pointer_width = "64",
            not(target_os = "haiku")
        ))]
        return self.f_blocks;
        #[cfg(any(
            not(target_pointer_width = "64"),
            target_os = "haiku",
        ))]
        return self.f_blocks.into();
    }

I feel like these could all be condensed into just return self.f_blocks.into(); which would cover all cases, but i'm also assuming the width check is for a reason?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions