From: Robert Lipe Date: Sun, 30 Oct 2022 03:45:20 +0000 (-0500) Subject: Don't make it easy to iterate the state_t enum...except when we do. (#939) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~1^2~168 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ef1737aaa85168d85f2727cfb880eabc691f6262;p=gpsbabel.git Don't make it easy to iterate the state_t enum...except when we do. (#939) --- diff --git a/brauniger_iq.cc b/brauniger_iq.cc index 71c790c1b..7074caac2 100644 --- a/brauniger_iq.cc +++ b/brauniger_iq.cc @@ -48,18 +48,8 @@ namespace { // fix ODR violation with igc num_states }; } -static state_t state; -inline state_t& operator++(state_t& s) // prefix -{ - return s = static_cast(s + 1); -} -inline state_t operator++(state_t& s, int) // postfix -{ - state_t ret(s); - ++s; - return ret; -} +static state_t state; static const int reqd_bytes[num_states] = { 6, 1, 2, 2, 25, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1 }; static void rd_init(const QString& fname) @@ -227,7 +217,12 @@ static int process_data(const unsigned char* data) default: fatal(MYNAME ": Bad internal state\n"); } - ++state; + + // Iterating an enum isn't great and it's less greatr that reqd_byte[] is + // implicitly coupled to our state_t, but here we are with C code forged + // into C++. + state = static_cast (state + 1); + return remaining; }