]> git.notmuchmail.org Git - notmuch/commitdiff
Avoid spurious gcc warning in debugger.c
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sat, 6 Oct 2018 20:34:49 +0000 (15:34 -0500)
committerDavid Bremner <david@tethera.net>
Sun, 21 Oct 2018 13:25:07 +0000 (10:25 -0300)
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.

debugger.c

index 5cb38ac444e35d774152b64973790c4fd5ec7f4d..0febf170d729167b6697f18fffaae467d8c84259 100644 (file)
@@ -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;
     }