This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix selftest::read_file for empty file
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: David Malcolm <dmalcolm at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Jul 2017 16:59:01 +0200
- Subject: Re: [PATCH] Fix selftest::read_file for empty file
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1FA22C04B940
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FA22C04B940
- References: <1500475773-32599-1-git-send-email-dmalcolm@redhat.com> <20170719145430.GB9043@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jul 19, 2017 at 04:54:31PM +0200, Marek Polacek wrote:
> > --- a/gcc/selftest.c
> > +++ b/gcc/selftest.c
> > @@ -192,7 +192,14 @@ read_file (const location &loc, const char *path)
> > fclose (f_in);
> >
> > /* 0-terminate the buffer. */
> > + if (total_sz == 0)
> > + {
> > + size_t new_alloc_sz = alloc_sz ? alloc_sz * 2: total_sz + 1;
>
> There should be a space before ":". Also, if you know total_sz is 0, why
> "total_sz + 1" and not just "1"?
>
> > + result = (char *)xrealloc (result, new_alloc_sz);
>
> A space after ).
Or better
result = XRESIZEVEC (char, result, new_alloc_sz);
?
Jakub