Hi Janusz,
On 2024-07-18 at 10:55:15 +0200, Janusz Krzysztofik wrote:
> When opening a potential primary counterpart of a render device, we first
> open a parent directory of the render node and pass it to openat() that
> can open a path relative to that directory.  But on the other hand, we
> build and pass to that function a path of that primary that is absolute,
> not relative.  While that construct gives the expected result anyway, it
> makes the picture unclear.
> 
> Use open() and drop unused code.
> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzyszto...@linux.intel.com>

Reviewed-by: Kamil Konieczny <kamil.koniec...@linux.intel.com>


> ---
>  lib/i915/gem_engine_topology.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
> index 8589af5c1a..c8c1079223 100644
> --- a/lib/i915/gem_engine_topology.c
> +++ b/lib/i915/gem_engine_topology.c
> @@ -470,14 +470,10 @@ static int __open_primary(int dir)
>       if (igt_debug_on(readlinkat(dir, "device", target, sizeof(target)) < 0))
>               return dir;
>  
> -     fd = openat(dir, "..", O_RDONLY);
> -     if (fd < 0)
> -             return dir;
> -
>       close(dir);
>       for (minor = 0; minor < 64; minor++) {
>               sprintf(buf, "/sys/dev/char/%d:%d", major, minor);
> -             dir = openat(fd, buf, O_RDONLY);
> +             dir = open(buf, O_RDONLY);
>               if (dir < 0)
>                       continue;
>  
> @@ -488,7 +484,6 @@ static int __open_primary(int dir)
>               close(dir);
>               dir = -1;
>       }
> -     close(fd);
>  
>       return dir;
>  }
> -- 
> 2.45.2
> 

Reply via email to