diff mbox

Ping! gengtype plugin improvement last2round - patch 1 [declprog]

Message ID 20101018074050.aa438178.basile@starynkevitch.net
State New
Headers show

Commit Message

Basile Starynkevitch Oct. 18, 2010, 5:40 a.m. UTC
On Mon, 18 Oct 2010 06:47:30 +0300
Laurynas Biveinis <laurynas.biveinis@gmail.com> wrote:

> 2010/10/17 Basile Starynkevitch <basile@starynkevitch.net>:
> > There remains a bug in the code,  plugin_files was not allocated.
> 
> > 2010-10-17  Basile Starynkevitch  <basile@starynkevitch.net>
> >        * gengtype.c (parse_program_options): Allocate plugin_files.
> 
> The patch is OK - and it is obvious, IMHO.
> 
> However, while reviewing this I found the following in main:
> 
>       if (nb_plugin_files <= 0 || !plugin_files)
>         fatal ("No plugin files given in plugin mode for %s",
>                plugin_output_filename);
> 
> nb_plugin_files is of size_t, which is unsigned. Please replace with ==.

I just committed the following patch to trunk:


With the gcc/ChangeLog entry:
2010-10-18  Basile Starynkevitch  <basile@starynkevitch.net>

	* gengtype.c (parse_program_options): Added allocation of
	plugin_files, and corrected test on nb_plugin_files.

Committed revision 165608.

Comments

Eric Botcazou Oct. 18, 2010, 8:37 a.m. UTC | #1
> 2010-10-18  Basile Starynkevitch  <basile@starynkevitch.net>
>
> 	* gengtype.c (parse_program_options): Added allocation of
> 	plugin_files, and corrected test on nb_plugin_files.

Present tense only in ChangeLog entries: "Add allocation..."
Basile Starynkevitch Oct. 18, 2010, 4:39 p.m. UTC | #2
On Mon, 18 Oct 2010 10:37:48 +0200
Eric Botcazou <ebotcazou@adacore.com> wrote:

> > 2010-10-18  Basile Starynkevitch  <basile@starynkevitch.net>
> >
> > 	* gengtype.c (parse_program_options): Added allocation of
> > 	plugin_files, and corrected test on nb_plugin_files.
> 
> Present tense only in ChangeLog entries: "Add allocation..."

I svn commit-ed the trivial correction to ChangeLog.

Thanks
Eric Botcazou Oct. 18, 2010, 4:59 p.m. UTC | #3
> I svn commit-ed the trivial correction to ChangeLog.

Thanks!
diff mbox

Patch

Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 165607)
+++ gcc/gengtype.c	(working copy)
@@ -4395,6 +4395,7 @@  parse_program_options (int argc, char **argv)
       if (optind >= argc)
 	fatal ("no source files given in plugin mode");
       nb_plugin_files = argc - optind;
+      plugin_files = XNEWVEC (char*, nb_plugin_files);
       for (i = 0; i < (int) nb_plugin_files; i++)
 	{
 	  char *name = argv[i + optind];
@@ -4488,7 +4489,7 @@  main (int argc, char **argv)
 	fatal ("No read state given in plugin mode for %s",
 	       plugin_output_filename);
 
-      if (nb_plugin_files <= 0 || !plugin_files)
+      if (nb_plugin_files == 0 || !plugin_files)
 	fatal ("No plugin files given in plugin mode for %s",
 	       plugin_output_filename);