Fix misc warnings reported by cppcheck

https://bugs.freedesktop.org/show_bug.cgi?id=65544