cppcheck: fix possible null deref and unused structs