Re: [evolution-patches] Patch for #47874, GAL and calendar related



Ah... one should never 'test & do' but 'do & test'.

That is, in the in-between testing and opening, something bad could
happen.

What should be done is try to open and test whether open is successful
(and what error did it cause, if any).

As one can see in
http://xmlsoft.org/html/libxml-parser.html#xmlParseFile

xmlParseFile returns NULL if anything bad happens so the if(doc) and
if(!doc) tests that are made conform to the rule of 'do & test'

So what is being added is an irrelevant (and dangerous) test.

Maybe those if's should be changed into something like:

   if(doc) {
    ...
   } else {
      return FALSE;
   }

But I haven't checked if they do that already.

Hugs, Rui

On Mon, 2003-08-25 at 15:40, Mike Kestner wrote:
> Looks good.  Thanks for the patch.  Please commit to the stable branch
> and trunk.
> 
> Mike
> 
> On Mon, 2003-08-25 at 05:59, Harry Lu wrote:
> > GAL maintainers,
> >     Please reivew my patch for #47874 based on HEAD.
> >     Thanks!
> >        Harry
> > 
> > ______________________________________________________________________
> > 
> > Index: gal/e-table/ChangeLog
> > ===================================================================
> > RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
> > retrieving revision 1.912
> > diff -u -r1.912 ChangeLog
> > --- gal/e-table/ChangeLog	19 Aug 2003 17:27:36 -0000	1.912
> > +++ gal/e-table/ChangeLog	25 Aug 2003 10:49:29 -0000
> > @@ -1,3 +1,12 @@
> > +2003-08-25  Harry Lu  <harry lu sun com>
> > +
> > +	** For bug #47874.
> > +
> > +	* e-table-specification.c (e_table_specification_load_from_file):
> > +	check whether file exists before call xmlParseFile().
> > +	* e-table-state.c (e_table_state_load_from_file): ditto.
> > +	* e-tree-table-adapter.c (open_file): ditto.
> > +
> >  2003-08-19  Mike Kestner  <mkestner ximian com>
> >  
> >  	* e-cell-tree.c (draw_expander): add an expander_style param
> > Index: gal/e-table/e-table-specification.c
> > ===================================================================
> > RCS file: /cvs/gnome/gal/gal/e-table/e-table-specification.c,v
> > retrieving revision 1.28
> > diff -u -r1.28 e-table-specification.c
> > --- gal/e-table/e-table-specification.c	19 Jun 2003 15:31:31 -0000	1.28
> > +++ gal/e-table/e-table-specification.c	25 Aug 2003 10:49:29 -0000
> > @@ -129,6 +129,10 @@
> >  				      const char          *filename)
> >  {
> >  	xmlDoc *doc;
> > +
> > +	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
> > +		return FALSE;
> > +
> >  	doc = xmlParseFile (filename);
> >  	if (doc) {
> >  		xmlNode *node = xmlDocGetRootElement (doc);
> > Index: gal/e-table/e-table-state.c
> > ===================================================================
> > RCS file: /cvs/gnome/gal/gal/e-table/e-table-state.c,v
> > retrieving revision 1.28
> > diff -u -r1.28 e-table-state.c
> > --- gal/e-table/e-table-state.c	15 Jan 2003 19:42:14 -0000	1.28
> > +++ gal/e-table/e-table-state.c	25 Aug 2003 10:49:29 -0000
> > @@ -120,6 +120,10 @@
> >  				 const char          *filename)
> >  {
> >  	xmlDoc *doc;
> > +
> > +	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
> > +		return FALSE;
> > +
> >  	doc = xmlParseFile (filename);
> >  	if (doc) {
> >  		xmlNode *node = xmlDocGetRootElement(doc);
> > Index: gal/e-table/e-tree-table-adapter.c
> > ===================================================================
> > RCS file: /cvs/gnome/gal/gal/e-table/e-tree-table-adapter.c,v
> > retrieving revision 1.56
> > diff -u -r1.56 e-tree-table-adapter.c
> > --- gal/e-table/e-tree-table-adapter.c	12 Jun 2003 13:35:46 -0000	1.56
> > +++ gal/e-table/e-tree-table-adapter.c	25 Aug 2003 10:49:30 -0000
> > @@ -925,6 +925,9 @@
> >  	int vers;
> >  	gboolean model_default, saved_default;
> >  
> > +	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
> > +		return NULL;
> > +
> >  	doc = xmlParseFile (filename);
> >  	if (!doc)
> >  		return NULL;
-- 
+ No matter how much you do, you never do enough -- unknown
+ Whatever you do will be insignificant,
| but it is very important that you do it -- Gandhi
+ So let's do it...?

Please AVOID sending me WORD, EXCEL or POWERPOINT attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]