"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: tog: unconditionally set x/y in view_get_split()
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 30 Jun 2022 17:10:07 +1000

Download raw body.

Thread
On 22-06-30 09:05am, Omar Polo wrote:
> Mark Jamsek <mark@jamsek.com> wrote:
> > Suggested by op on irc.
> > 
> > I noticed this when cooking the diff. We initialise begin_{x,y} in all
> > the callers so only conditionally set x/y pointers in view_get_split().
> > 
> > But for robustness, we should initialise here too.
> 
> yep!  what i was thinking is that maybe in the future someone calls
> view_get_split without knowing that only one of the pointers is written
> to and if they don't initialize the values to something sensible before
> it'll be fun :)

It's definitely the correct thing to do and I'm questioning why I didn't
just do it originally. I checked all the callers and decided not to. But
we'll be calling this a lot more as we expand hsplits to more child
views and then add key maps, so it's bound to have happened eventually!

I've probably chased down as many bugs from uninitialised vars as OB1s
:)

> > diff 9b058f456d15d60a89334ce3e7f0a7c22e182c55 /Users/mark/Library/Mobile Documents/com~apple~CloudDocs/src/got-current
> > blob - 6a0c6dbff39ee1a8db173cbc3fa1fbf0918eecab
> > file + tog/tog.c
> > --- tog/tog.c
> > +++ tog/tog.c
> > @@ -2858,6 +2858,9 @@ view_get_split(struct tog_view *view, int *y, int *x)
> >  {
> >  	char *mode;
> > 
> > +	*x = 0;
> > +	*y = 0;
> > +
> >  	mode = getenv("TOG_VIEW_SPLIT_MODE");
> > 
> >  	if (!mode || mode[0] != 'h') {
> 
> 

-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68