bytecodealliance/rustix

`fgetxattr` takes `&mut [u8]` but `flistxattr` takes `&mut [c_char]`

Closed this issue · 2 comments

Not sure if this inconsistency is intentional or unintentional, but I found it when trying to find justifications for adding a generic to BorrowedBuf, so I wanted to bring it up. I'm sure there are more inconsistencies like this, so it might be done to harmonize everything.

This difference comes from the C signatures of these functions:

ssize_t flistxattr(int fd, char *list, size_t size); 
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size); 

flistattr writes a buffer of C strings which are the keys, so it uses c_char. fgetxattr writes an arbitrary byte sequence, so it uses &mut [u8].

Do you have a use case where it's inconvenient that these are different?

Oh I completely misread the API and thought the name param was the one getting mapped to &mut [u8]. my bad!