[PATCH 1/2] lib/igt_facts: Make igt_facts_test noreturn

Gurram, Pravalika pravalika.gurram at intel.com
Tue Jan 21 09:14:05 UTC 2025



> -----Original Message-----
> From: Peter Senna Tschudin <peter.senna at linux.intel.com>
> Sent: Tuesday, January 21, 2025 1:51 PM
> To: Gurram, Pravalika <pravalika.gurram at intel.com>; igt-
> dev at lists.freedesktop.org; kamil.konieczny at linux.intel.com
> Subject: Re: [PATCH 1/2] lib/igt_facts: Make igt_facts_test noreturn
> 
> Hi Pravalika,
> 
> On 21.01.2025 07:32, Pravalika Gurram wrote:
> > noreturn attribute is used to improve the optimization by informing to
> > the compiler that function does not return .
> >
> > Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> > ---
> >  lib/igt_facts.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/igt_facts.c b/lib/igt_facts.c index
> > 2e04a7c86..bd6742065 100644
> > --- a/lib/igt_facts.c
> > +++ b/lib/igt_facts.c
> > @@ -748,7 +748,7 @@ static void igt_facts_test_mark_and_sweep(struct
> igt_list_head *head)
> >   *
> >   * Returns: bool indicating if the tests passed
> >   */
> > -void igt_facts_test(void)
> > +__noreturn void igt_facts_test(void)
> 
> How did you find this? Is the compiler complaining?
> 
When am fixing the check patch errors I have seen below error 

ninja: Entering directory `build'
[2/835] Compiling C object lib/libigt-igt_facts_c.a.p/igt_facts.c.o
../lib/igt_facts.c: In function ‘igt_facts_test’:
../lib/igt_facts.c:751:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
  751 | void igt_facts_test(void)
      |      ^~~~~~~~~~~~~~
[6/6] Generating docs/testplan/intel-ci-tests with a custom command

Then have added changes.
> >  {
> >  	const char *last_test = "Unit Testing";
> >
> > @@ -776,4 +776,6 @@ void igt_facts_test(void)
> >  	/* Clean up the list and call igt_facts(). This should not crash */
> >  	igt_facts_list_mark_and_sweep(&igt_facts_list_pci_gpu_head);
> >  	igt_facts(last_test);
> > +
> > +	igt_exit();
> >  }
> Why adding igt_exit() here?
> 
> How did you test this patch?
> 
If we don’t explicitly specify igt_exit() I will below warning 

ninja: Entering directory `build'
[43/999] Compiling C object lib/libigt-igt_facts_c.a.p/igt_facts.c.o
../lib/igt_facts.c: In function ‘igt_facts_test’:
../lib/igt_facts.c:779:1: warning: ‘noreturn’ function does return
  779 | }
      | ^
I have compiled since these check patch errors

> Thanks,
> 
> Peter


More information about the igt-dev mailing list