On 2023-05-15 12:43, Ondrej Valousek wrote:
> You feed listxattr() with a buffer sized like trivial_NFS4_attr_buf - that just does not seem to be correct right? That trivial_NFS4_attr_buf serves smth completely different.
All that listxattr needs is a nonzero-sized buffer. It's OK for a union
to hold unrelated objects so long as it doesn't hold them at the same
time, which is the case here.
The code could allocate two distinct stack buffers of different types,
but that'd use more stack space and put more pressure on caches. It
could even allocate the distinct buffers in non-overlapping compound
statements, but GCC isn't good about optimizating that and anyway the
code would get trickier in a different way.