Fix a cppcheck warning about case labels.
For this code, cppcheck warned: "Label 'case0' is not used. Should this be a 'case' of the enclosing switch()?" Ditto for 'case1' and for 'case2'. I'm not sure why it was complaining, because these certainly look like switch cases to me. Perhaps moving the static variable declaration to outside of the switch will help.