This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix selftest::read_file for empty file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]