[Intel-gfx] [PATCH i-g-t 1/7] Remove parameter aliases with another argument

Arkadiusz Hiler arkadiusz.hiler at intel.com
Tue Jul 10 13:50:34 UTC 2018


On Sat, Jul 07, 2018 at 08:22:25PM -0300, Rodrigo Siqueira wrote:
> This commit fixes the following GCC warning:
> 
> warning: passing argument 2 to restrict-qualified parameter aliases with
> argument 1 [-Wrestrict]
>   return (readlink (buf, buf, sizeof (buf)) != -1 &&
> 
> This commit fixes the GCC warning by creating a second buffer only to
> keep the path.
> 
> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com>
> ---
>  lib/igt_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 3313050c..fa22f12d 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -1169,10 +1169,10 @@ bool igt_can_fail(void)
>  
>  static bool run_under_gdb(void)
>  {
> -	char buf[1024];
> +	char pathname[1024], buf[1024];

1024 for pathname is quite an overshoot. We stash at most
"/proc/%d/exec" where %d should be at most 21 or so.

> -	sprintf(buf, "/proc/%d/exe", getppid());
> -	return (readlink (buf, buf, sizeof (buf)) != -1 &&
> +	sprintf(pathname, "/proc/%d/exe", getppid());
> +	return (readlink (pathname, buf, sizeof (buf)) != -1 &&

                        ^ while we are here we can get rid of that space

>  		strncmp(basename(buf), "gdb", 3) == 0);
>  }
>  
> -- 
> 2.18.0
> 


More information about the Intel-gfx mailing list