CID#18192 Unsigned compared against 0

Here namesize was of type size_t and could store
a negative value. ssize_t is prefered in this case
since we want to catch a negative return value
treated as an error.
CID#18162 Unsigned compared against 0

Here namesize was of type size_t and could store
a negative value. ssize_t is prefered in this case
since we want to catch a negative return value
treated as an error.
CID#18482 Unsigned compared against 0

Here namesize was of type size_t and could store
a negative value. ssize_t is prefered in this case
since we want to catch a negative return value
treated as an error.
CID#18458 Missing unlock

When returning EINVAL, the handle mutex wasn't released.
This is to be more consistent with the normal case where
the lock is released. I don't think it's required to
destroy it though.