Re: [PATCH v8 06/22] perf arm-spe: Refactor printing string to buffer

From: Arnaldo Carvalho de Melo
Date: Wed Nov 11 2020 - 12:40:16 EST


Em Wed, Nov 11, 2020 at 03:58:27PM +0000, Dave Martin escreveu:
> On Wed, Nov 11, 2020 at 03:53:20PM +0000, Dave Martin wrote:
> > On Wed, Nov 11, 2020 at 07:11:33AM +0000, Leo Yan wrote:
> > > When outputs strings to the decoding buffer with function snprintf(),
> > > SPE decoder needs to detects if any error returns from snprintf() and if
> > > so needs to directly bail out. If snprintf() returns success, it needs
> > > to update buffer pointer and reduce the buffer length so can continue to
> > > output the next string into the consequent memory space.
> > >
> > > This complex logics are spreading in the function arm_spe_pkt_desc() so
> > > there has many duplicate codes for handling error detecting, increment
> > > buffer pointer and decrement buffer size.
> > >
> > > To avoid the duplicate code, this patch introduces a new helper function
> > > arm_spe_pkt_snprintf() which is used to wrap up the complex logics, and
> > > it's used by the caller arm_spe_pkt_desc().
> > >
> > > This patch also moves the variable 'blen' as the function's local
> > > variable, this allows to remove the unnecessary braces and improve the
> > > readability.
> > >
> > > Suggested-by: Dave Martin <Dave.Martin@xxxxxxx>
> > > Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
> > > Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx>
> >
> > Mostly looks fine to me now, thought there are a few potentionalu
> > issues -- comments below.
>
> Hmm, looks like patch 7 anticipated some of my comments here.
>
> Rather than fixing up patch 6, maybe it would be better to squash these
> patches together after all... sorry!

I'll take a look and probably do that, as it is what Andre suggests.

- Arnaldo