Message ID | 1fdd00077524f8c4703095a67caa3d0f920e3c05.1531005542.git.rodrigosiqueiramelo@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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@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 >
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]; - 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 && strncmp(basename(buf), "gdb", 3) == 0); }
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@gmail.com> --- lib/igt_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)