fix cmd index bug; use -Wall -Werror