[igt-dev] [PATCH i-g-t v4 01/77] lib: Introduce typed cleanups

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Wed Oct 5 10:22:52 UTC 2022


On Wed, 5 Oct 2022 12:01:46 +0200
Kamil Konieczny <kamil.konieczny at linux.intel.com> wrote:

> Hi Mauro,
> 
> On 2022-10-05 at 09:44:30 +0200, Mauro Carvalho Chehab wrote:
> > From: Chris Wilson <chris at chris-wilson.co.uk>  
> 
> imho here should be added "why" part, consider adding
> something like following (re-worded from cover letter):
> 
> We close devices on exit but that doesn't work when inside
> igt_subtest_group is used igt_skip(), as it uses longjmp,
> causing the code to go out of scope and miss close(). 
> 
> > 
> > Start introducing standard types with automatic cleanup courtesy of
> > gcc's __attribute__((cleanup)). As an example, we start with an fd
> > that will automatically call close() on going out of scope, and
> > crucially before atexit where we will want to check for resource leaks.
> > 
> > [mchehab: add test descriptions]
> > Suggested-by: Andrzej Hajda <andrzej.hajda at intel.com>
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > Cc: Andrzej Hajda <andrzej.hajda at intel.com>
> > Reviewed-by: Petri Latvala <petri.latvala at intel.com>
> > Acked-by: Nirmoy Das <nirmoy.das at linux.intel.com>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>  

Makes sense. Changing it to:

    lib: Introduce typed cleanups
    
    We close devices on exit but that doesn't work when inside
    igt_subtest_group is used igt_skip(), as it uses longjmp,
    causing the code to go out of scope and miss close().
    
    Start introducing standard types with automatic cleanup courtesy of
    gcc's __attribute__((cleanup)). This also works with clang, when
    using volatile integers.
    
    As an example, we start with an fd that will automatically call
    close() on going out of scope, and crucially before atexit where
    we will want to check for resource leaks.
    
    [mchehab: add test descriptions]
    Suggested-by: Andrzej Hajda <andrzej.hajda at intel.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Andrzej Hajda <andrzej.hajda at intel.com>
    Reviewed-by: Petri Latvala <petri.latvala at intel.com>
    Acked-by: Nirmoy Das <nirmoy.das at linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>

Regards,
Mauro


More information about the igt-dev mailing list