Fix some coverity defects:
* Unused pointer value (UNUSED_VALUE)
* Unchecked return value (CHECKED_RETURN)
* Unchecked return value from library (CHECKED_RETURN)
* Dereference before null check (REVERSE_INULL)