Test for ENOMEM.
Just minor layout changes.
Prefer buffer size over namesize+1.
More nitpicking.