Fix build with clang

This fixes some type confusions and some checks for conditions that
can't happen.

Change-Id: If50e7af175d58c0352536071bb3752f3d063c349
3 files changed