Given all the ANSI control states are sequential in the vc_ctl_state
enum, we can define first/last constants and use them in
ansi_control_string(). It makes the test simple and allows for removal
of the 'if' (which was unnecessary at all -- the 'return' should have
returned the 'if' content directly anyway).
And remove the useless comment -- it's clear from the function
prototype.
Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20240202065608.14019-17-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* @ESnonstd: OSC parsed
* @ESpalette: OSC P parsed
* @ESosc: OSC [0-9] parsed
+ * @ESANSI_first: first state for ignoring ansi control sequences
* @ESapc: ESC _ parsed
* @ESpm: ESC ^ parsed
* @ESdcs: ESC P parsed
+ * @ESANSI_last: last state for ignoring ansi control sequences
*/
enum vc_ctl_state {
ESnormal,
ESnonstd,
ESpalette,
ESosc,
+ ESANSI_first = ESosc,
ESapc,
ESpm,
ESdcs,
+ ESANSI_last = ESdcs,
};
/* console_lock is held (except via vc_init()) */
vc->vc_translate = set_translate(*charset, vc);
}
-/* is this state an ANSI control string? */
-static bool ansi_control_string(unsigned int state)
+static bool ansi_control_string(enum vc_ctl_state state)
{
- if (state == ESosc || state == ESapc || state == ESpm || state == ESdcs)
- return true;
- return false;
+ return state >= ESANSI_first && state <= ESANSI_last;
}
enum {