Re: [PATCH] tty: vt: saturate scrollback_delta to avoid overflow
From: Justin Stitt
Date: Thu May 09 2024 - 18:04:28 EST
On Thu, May 9, 2024 at 3:01 PM Justin Stitt <justinstitt@xxxxxxxxxx> wrote:
>
>
> Agreed.
>
> Does an implementation like this look any better?
>
> static inline void scrolldelta(int lines)
> {
> ...
> /* saturate scrollback_delta so that it never wraps around */
> if (lines > 0)
> scrollback_delta = min(scrollback_delta, INT_MAX -
> lines) + lines;
> else
> scrollback_delta = max(scrollback_delta, INT_MIN -
> lines) + lines;
> schedule_console_callback();
> }
I apologize for this formatting, gmail ate my tabs.
Note to self, do NOT copy/paste from vim to gmail's web client.
> Thanks
> Justin