Fix warnings reported by IntelliJ

Fixup various warnings reported by running analyze from
IntelliJ.

Change-Id: I9bca5f7950d04c64ac6c71aa416eb7e6bd056433
Reviewed-on: http://review.couchbase.org/27629
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>