unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Avoid spurious gcc warning in debugger.c
@ 2018-10-06 20:34 Daniel Kahn Gillmor
  2018-10-08 15:42 ` David Bremner
  2018-10-21 13:34 ` David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Kahn Gillmor @ 2018-10-06 20:34 UTC (permalink / raw)
  To: Notmuch Mail

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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;
     }
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Avoid spurious gcc warning in debugger.c
  2018-10-06 20:34 [PATCH] Avoid spurious gcc warning in debugger.c Daniel Kahn Gillmor
@ 2018-10-08 15:42 ` David Bremner
  2018-10-08 15:47   ` David Edmondson
  2018-10-21 13:34 ` David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2018-10-08 15:42 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, Notmuch Mail

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> 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 &&
>                    ~~~  ^~~
>

There seems to be some overlap with dme's recent patch

      id:20181004094545.18710-1-dme@dme.org

Could one or both of you maybe produce a merged series?

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Avoid spurious gcc warning in debugger.c
  2018-10-08 15:42 ` David Bremner
@ 2018-10-08 15:47   ` David Edmondson
  2018-10-08 16:04     ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2018-10-08 15:47 UTC (permalink / raw)
  To: David Bremner, Daniel Kahn Gillmor, Notmuch Mail

On Monday, 2018-10-08 at 12:42:18 -03, David Bremner wrote:

> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>
>> 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 &&
>>                    ~~~  ^~~
>>
>
> There seems to be some overlap with dme's recent patch
>
>       id:20181004094545.18710-1-dme@dme.org
>
> Could one or both of you maybe produce a merged series?

The change is really the same.

dme.
-- 
I just bite it, it's for the look I don't light it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Avoid spurious gcc warning in debugger.c
  2018-10-08 15:47   ` David Edmondson
@ 2018-10-08 16:04     ` Daniel Kahn Gillmor
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kahn Gillmor @ 2018-10-08 16:04 UTC (permalink / raw)
  To: David Edmondson, David Bremner, Notmuch Mail

On Mon 2018-10-08 16:47:08 +0100, David Edmondson wrote:
> On Monday, 2018-10-08 at 12:42:18 -03, David Bremner wrote:
>
>> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>>
>>> 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 &&
>>>                    ~~~  ^~~
>>>
>>
>> There seems to be some overlap with dme's recent patch
>>
>>       id:20181004094545.18710-1-dme@dme.org
>>
>> Could one or both of you maybe produce a merged series?
>
> The change is really the same.

i'm fine with either one as well.  thanks, and sorry that i missed dme's
proposal when preparing this one.

    --dkg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Avoid spurious gcc warning in debugger.c
  2018-10-06 20:34 [PATCH] Avoid spurious gcc warning in debugger.c Daniel Kahn Gillmor
  2018-10-08 15:42 ` David Bremner
@ 2018-10-21 13:34 ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2018-10-21 13:34 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, Notmuch Mail

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> 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.

pushed,

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-21 13:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-06 20:34 [PATCH] Avoid spurious gcc warning in debugger.c Daniel Kahn Gillmor
2018-10-08 15:42 ` David Bremner
2018-10-08 15:47   ` David Edmondson
2018-10-08 16:04     ` Daniel Kahn Gillmor
2018-10-21 13:34 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).