kdb: Use format-strings rather than '\0' injection in kdb_read()
authorDaniel Thompson <daniel.thompson@linaro.org>
Wed, 24 Apr 2024 14:03:35 +0000 (15:03 +0100)
committerDaniel Thompson <daniel.thompson@linaro.org>
Fri, 26 Apr 2024 16:13:30 +0000 (17:13 +0100)
commit09b35989421dfd5573f0b4683c7700a7483c71f9
tree344e717dcc4cb01bfbc8211f27061a60dc5526e2
parente9730744bf3af04cda23799029342aa3cddbc454
kdb: Use format-strings rather than '\0' injection in kdb_read()

Currently when kdb_read() needs to reposition the cursor it uses copy and
paste code that works by injecting an '\0' at the cursor position before
delivering a carriage-return and reprinting the line (which stops at the
'\0').

Tidy up the code by hoisting the copy and paste code into an appropriately
named function. Additionally let's replace the '\0' injection with a
proper field width parameter so that the string will be abridged during
formatting instead.

Cc: stable@vger.kernel.org # Not a bug fix but it is needed for later bug fixes
Tested-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20240424-kgdb_read_refactor-v3-2-f236dbe9828d@linaro.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
kernel/debug/kdb/kdb_io.c