[PATCH] x86: Update cbmem driver

Simon Glass sjg at chromium.org
Tue Aug 15 00:42:46 CEST 2023


Hi Alex,

On Sun, 13 Aug 2023 at 21:03, Alex Sadovsky
<nable.maininbox at googlemail.com> wrote:
>
> Dear Simon and other developers,
> > -     cursor = cbmem_console_p->buffer_cursor++;
> > -     if (cursor < cbmem_console_p->buffer_size)
> > -             cbmem_console_p->buffer_body[cursor] = data;
> > +     pos = cons->cursor++;
> > +     if (pos < cons->size)
> > +             cons->body[pos] = data;
> While at it, is it OK to increment cons->cursor unconditionally,
> even when the buffer is full?
>
> It's better to do it after the check, isn't it? E.g.:
>
>         if (cons->cursor < cons->size)
>                 cons->body[cons->cursor++] = data;

I believe the original intent was to indicate that the buffer had
overflowed. But prompted by your review I took a look at the coreboot
implementation and it now has an overflow flag.

So I will send a v2 incorporating this.

Thanks,
Simon


More information about the U-Boot mailing list