[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=WpHKRGdtnRpq+Bxj0CYX3wUvYV0OmRe0V=zMwVn1AHTQ@mail.gmail.com>
Date: Mon, 22 Apr 2024 16:52:39 -0700
From: Doug Anderson <dianders@...omium.org>
To: Daniel Thompson <daniel.thompson@...aro.org>
Cc: Jason Wessel <jason.wessel@...driver.com>, kgdb-bugreport@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 6/7] kdb: Replace double memcpy() with memmove() in kdb_read()
Hi,
On Mon, Apr 22, 2024 at 9:38 AM Daniel Thompson
<daniel.thompson@...aro.org> wrote:
>
> At several points in kdb_read() there are variants of the following
> code pattern (with offsets slightly altered):
>
> memcpy(tmpbuffer, cp, lastchar - cp);
> memcpy(cp-1, tmpbuffer, lastchar - cp);
> *(--lastchar) = '\0';
>
> There is no need to use tmpbuffer here, since we can use memmove() instead
> so refactor in the obvious way. Additionally the strings that are being
> copied are already properly terminated so let's also change the code so
> that the library calls also move the terminator.
>
> Changing how the terminators are managed has no functional effect for now
> but might allow us to retire lastchar at a later point. lastchar, although
> stored as a pointer, is functionally equivalent to caching strlen(buffer).
>
> Signed-off-by: Daniel Thompson <daniel.thompson@...aro.org>
> ---
> kernel/debug/kdb/kdb_io.c | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)
Reviewed-by: Douglas Anderson <dianders@...omium.org>
Powered by blists - more mailing lists