From: Daniel Kahn Gillmor Date: Sat, 6 Oct 2018 20:34:49 +0000 (-0500) Subject: Avoid spurious gcc warning in debugger.c X-Git-Tag: archive/debian/0.29_rc0-1~160 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=daec80eedabcafaf85ac58802451d165e0696745;ds=sidebyside Avoid spurious gcc warning in debugger.c Without this patch, gcc 8.2.0-7 complains: debugger.c: In function ‘debugger_is_active’: debugger.c:40:24: warning: passing argument 2 to restrict-qualified parameter aliases with argument 1 [-Wrestrict] if (readlink (buf, buf, sizeof (buf)) != -1 && ~~~ ^~~ This is pretty silly, but it seems simplest to just avoid passing the same buffer to readlink as both pathname and buf. --- diff --git a/debugger.c b/debugger.c index 5cb38ac4..0febf170 100644 --- a/debugger.c +++ b/debugger.c @@ -32,13 +32,14 @@ bool debugger_is_active (void) { char buf[1024]; + char buf2[1024]; if (RUNNING_ON_VALGRIND) return true; sprintf (buf, "/proc/%d/exe", getppid ()); - if (readlink (buf, buf, sizeof (buf)) != -1 && - strncmp (basename (buf), "gdb", 3) == 0) + if (readlink (buf, buf2, sizeof (buf2)) != -1 && + strncmp (basename (buf2), "gdb", 3) == 0) { return true; }