[igt-dev] [PATCH i-g-t] lib/igt_eld: fix eld_is_supported failing if not supported

Ser, Simon simon.ser at intel.com
Fri Sep 13 10:58:13 UTC 2019


On Fri, 2019-09-13 at 13:42 +0300, Petri Latvala wrote:
> On Fri, Sep 13, 2019 at 01:23:40PM +0300, Simon Ser wrote:
> > When glob(3) doesn't find any results, it returns GLOB_NOMATCH.
> > I've been
> > confused by GLOB_NOCHECK's description and thought it would return
> > 0.
> > 
> > Instead of failing on the assert, return that ELDs aren't supported
> > in case
> > there's no match.
> > 
> > While at it, also include glob's return value in the assert
> > message.
> > 
> > Signed-off-by: Simon Ser <simon.ser at intel.com>
> > Fixes: 3374cd0b048f ("lib/igt_eld: introduce eld_is_supported")
> > Cc: Petri Latvala <petri.latvala at intel.com>
> > ---
> > 
> > Sorry about the fuss.
> > 
> >  lib/igt_eld.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/lib/igt_eld.c b/lib/igt_eld.c
> > index 5d1d8e01cd33..23ebf6305ae0 100644
> > --- a/lib/igt_eld.c
> > +++ b/lib/igt_eld.c
> > @@ -270,11 +270,14 @@ bool eld_has_igt(void)
> >  bool eld_is_supported(void)
> >  {
> >  	glob_t glob_buf = {0};
> > +	int ret;
> >  	bool has_elds;
> > 
> > -	igt_assert_f(glob("/proc/asound/card*/" ELD_PREFIX "*",
> > -			  GLOB_NOSORT, NULL, &glob_buf) == 0,
> > -		     "glob failed\n");
> > +	ret = glob("/proc/asound/card*/" ELD_PREFIX "*",
> > +		   GLOB_NOSORT, NULL, &glob_buf);
> > +	if (ret == GLOB_NOMATCH)
> > +		return false;
> > +	igt_assert_f(ret == 0, "glob failed: %d\n", ret);
> 
> Reviewed-by: Petri Latvala <petri.latvala at intel.com>

Thanks for the review. Please merge yourself when CI says it's fine, I
won't be there to do it.

> 
> >  	has_elds = glob_buf.gl_pathc > 0;
> >  	globfree(&glob_buf);
> > 
> > --
> > 2.23.0
> > 


More information about the igt-dev mailing list