Use bool here and there
More warn_unused_result attributes
nitpicking here and there.
nitpicking here and there.
add more function attributes.

We add the nonnull() attribute to enable gcc to warn us at compile time
instead of the runtime asserts (if asserts are present.)

Compile time warnings/errors are superior to run time warning.