Hi, On Tue, Oct 8, 2019 at 6:21 AM Daniel Thompson <daniel.thomp...@linaro.org> wrote: > > kdb_read_get_key() has extremely complex break/continue control flow > managed by state variables and is very hard to review or modify. In > particular the way the escape sequence handling interacts with the > general control flow is hard to follow. Separate out the escape key > handling, without changing the control flow. This makes the main body of > the code easier to review. > > Signed-off-by: Daniel Thompson <daniel.thomp...@linaro.org> > --- > kernel/debug/kdb/kdb_io.c | 127 ++++++++++++++++++++------------------ > 1 file changed, 66 insertions(+), 61 deletions(-) > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 3a5184eb6977..68e2c29f14f5 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -49,6 +49,63 @@ static int kgdb_transition_check(char *buffer) > return 0; > } > > +/* > + * kdb_read_handle_escape > + * > + * Run a validity check on an accumulated escape sequence. > + * > + * Returns -1 if the escape sequence is unwanted, 0 if it is incomplete, > + * otherwise it returns a mapped key value to pass to the upper layers. > + */ > +static int kdb_read_handle_escape(char *buf, size_t sz) > +{ > + char *lastkey = buf + sz - 1; > + > + switch (sz) { > + case 1: > + if (*lastkey == '\e') > + return 0;
Technically the "if" here isn't needed, at least not until a later patch in the series. The only way we could get here is if *lastkey == '\e'... ...but I suppose it's fine to keep it here in preparation for the last patch. Reviewed-by: Douglas Anderson <diand...@chromium.org> _______________________________________________ Kgdb-bugreport mailing list Kgdb-bugreport@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport