Misc fixes

A number of various fixes that the upcoming Sockets layer depends on
error: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]