From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning
Date: Fri, 5 Aug 2016 17:38:46 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1608051736400.5786@virtualbox> (raw)
In-Reply-To: <xmqqoa584eju.fsf@gitster.mtv.corp.google.com>
[-- Attachment #1: Type: text/plain, Size: 1916 bytes --]
Hi Junio,
On Thu, 4 Aug 2016, Junio C Hamano wrote:
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>
> > With GCC 6, the strdup() function is declared with the "nonnull"
> > attribute, stating that it is not allowed to pass a NULL value as
> > parameter.
> >
> > In nedmalloc()'s reimplementation of strdup(), Postel's Law is heeded
> > and NULL parameters are handled gracefully. GCC 6 complains about that
> > now because it thinks that NULL cannot be passed to strdup() anyway.
> >
> > Let's just shut up GCC >= 6 in that case and go on with our lives.
> >
> > See https://gcc.gnu.org/gcc-6/porting_to.html for details.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> > compat/nedmalloc/nedmalloc.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c
> > index 677d1b2..3f28c0b 100644
> > --- a/compat/nedmalloc/nedmalloc.c
> > +++ b/compat/nedmalloc/nedmalloc.c
> > @@ -956,6 +956,9 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **
> > char *strdup(const char *s1)
> > {
> > char *s2 = 0;
> > +#if __GNUC__ >= 6
> > +#pragma GCC diagnostic ignored "-Wnonnull-compare"
> > +#endif
> > if (s1) {
> > size_t len = strlen(s1) + 1;
> > s2 = malloc(len);
>
> Is it a common convention to place "#pragma GCC diagnostic"
> immediately before the statement you want to affect, and have the
> same pragma in effect until the end of the compilation unit?
Uh oh. This was a brain fart. I somehow confused the way pragmas work with
the way __attribute__s work. You are correct, of course, that the pragma
affects the entire remainder of the file, not just this statement.
Luckily, René came up with a much more elegant solution, so that Git's
history does not have to shame me eternally.
Ciao,
Dscho
next prev parent reply other threads:[~2016-08-05 15:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 16:07 [PATCH 0/2] Patches to let Git build with GCC 6 and DEVELOPER=SureWhyNot Johannes Schindelin
2016-08-04 16:07 ` [PATCH 1/2] nedmalloc: fix misleading indentation Johannes Schindelin
2016-08-04 16:07 ` [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning Johannes Schindelin
2016-08-04 17:41 ` Junio C Hamano
2016-08-05 15:38 ` Johannes Schindelin [this message]
2016-08-04 21:56 ` René Scharfe
2016-08-04 22:33 ` Junio C Hamano
2016-08-04 22:39 ` Junio C Hamano
2016-08-05 5:36 ` Johannes Sixt
2016-08-05 5:40 ` Johannes Sixt
2016-08-05 6:24 ` Junio C Hamano
2016-08-05 7:42 ` Jeff King
2016-08-05 15:34 ` Johannes Schindelin
2016-08-05 16:13 ` Junio C Hamano
2016-08-06 8:19 ` Johannes Schindelin
2016-08-05 21:57 ` Junio C Hamano
2016-08-05 22:30 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1608051736400.5786@virtualbox \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).