Set TMPDIR to a new temporary directory
free(NULL) is fine; drop pointless check
Clean up whitespace
Introduce _cleanup_free_ and _cleanup_close and start using them
Whitespace cleanup
fstat takes an fd