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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux