cppcheck: fix 1 'else if' cond matches previous cond + test indice before using it