Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	igt-dev@lists.freedesktop.org,
	Kunal Joshi <kunal1.joshi@intel.com>
Subject: Re: [PATCH i-g-t 2/3] lib/kms: Simplify force_connectors[] error handling
Date: Thu, 11 Apr 2024 16:23:20 +0300	[thread overview]
Message-ID: <ZhfkSJdayjDYejQZ@intel.com> (raw)
In-Reply-To: <20240411082511.sovecvuopmcuhcnr@kamilkon-desk.igk.intel.com>

On Thu, Apr 11, 2024 at 10:25:11AM +0200, Kamil Konieczny wrote:
> Hi Ville,
> On 2024-04-10 at 18:02:28 +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > The failure to allocate a forced_connector entry is entirely
> > our own fault. If we hit this then we've screwd up and made
> > the array too small. Skip the error handling and just assert
> > that we must have enough room in the array.
> > 
> > Cc: Kunal Joshi <kunal1.joshi@intel.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  lib/igt_kms.c | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> > index f7dd1db91827..19bb4ac66ece 100644
> > --- a/lib/igt_kms.c
> > +++ b/lib/igt_kms.c
> > @@ -1518,8 +1518,7 @@ static struct igt_forced_connector *forced_connector_alloc(void)
> >  	for (i = 0; forced_connectors[i].connector_type; i++)
> >  		;
> >  
> > -	if (i >= ARRAY_SIZE(forced_connectors))
> > -		return NULL;
> > +	igt_assert_lt(i, ARRAY_SIZE(forced_connectors));
> 
> Asserts in libs are ugly, could we just realloc it once?

We never realloc anything. It's a static array.

> Btw (i == ARRAY_SIZE(forced_connectors) should be ok? Or do
> we treat this as a end-of-array guard?

That's past the end of the array.

> 
> If you insist on keeping assert please at least give a message
> for ease of debug.

Looks like I actually dropped the assert entirely in the next patch
and let it explode naturally. Which it actually did in CI because
I made a booboo in _alloc()...

> 
> Regards,
> Kamil
> 
> >  
> >  	return &forced_connectors[i];
> >  }
> > @@ -1558,11 +1557,6 @@ static bool force_connector(int drm_fd,
> >  	}
> >  
> >  	c = forced_connector_alloc();
> > -	if (!c) {
> > -		igt_warn("Connector limit reached, %s will not be reset\n", name);
> > -		close(dir);
> > -		return true;
> > -	}
> >  
> >  	c->idx = idx;
> >  	c->connector_type = connector->connector_type;
> > -- 
> > 2.43.2
> > 

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2024-04-11 13:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 15:02 [PATCH i-g-t 1/3] lib/kms: Introduce struct igt_forced_connector Ville Syrjala
2024-04-10 15:02 ` [PATCH i-g-t 2/3] lib/kms: Simplify force_connectors[] error handling Ville Syrjala
2024-04-11  6:15   ` [i-g-t,2/3] " Joshi, Kunal1
2024-04-11  8:25   ` [PATCH i-g-t 2/3] " Kamil Konieczny
2024-04-11 13:23     ` Ville Syrjälä [this message]
2024-04-10 15:02 ` [PATCH i-g-t 3/3] lib/kms: Generalize forced_connectors[] to handle arbitrary attributes Ville Syrjala
2024-04-11  7:47   ` [i-g-t,3/3] " Joshi, Kunal1
2024-04-11 14:51     ` Ville Syrjälä
2024-04-10 23:56 ` ✗ CI.xeBAT: failure for series starting with [i-g-t,1/3] lib/kms: Introduce struct igt_forced_connector Patchwork
2024-04-11  0:17 ` ✗ Fi.CI.BAT: " Patchwork
2024-04-11  6:14 ` Joshi, Kunal1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZhfkSJdayjDYejQZ@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=kunal1.joshi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox