Re: oaf patch ...



Please check in but see my comment below.

Michael Meeks <michael@helixcode.com> writes:

> Oaf was crashing if type was not set in the XML for an iid and that iid
> was activated, this patch fixes it belt and braces, and adds a regression
> test:
> 
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/oaf/ChangeLog,v
> retrieving revision 1.61
> diff -u -r1.61 ChangeLog
> --- ChangeLog	2000/08/08 01:15:05	1.61
> +++ ChangeLog	2000/08/09 05:36:18
> @@ -1,3 +1,15 @@
> +2000-08-09  Michael Meeks  <michael@helixcode.com>
> +
> +	* test/Makefile.am: Stop broken.oafinfo installing by default; it gives
> +	errors.
> +
> +	* test/oaf-test-client.c (main): Add more tests.
> +
> +	* oafd/od-load.c (OAF_ServerInfo_load): update checks, & allocations.
> +	(od_validate_iid): rename to (od_validate): and make errors more friendly.
> +
> +	* oafd/ac-corba.c (ac_do_activation): check server_type before strcmp
> +
>  2000-08-07  Maciej Stachowiak  <mjs@eazel.com>
>  
>  	* CVSVERSION: New file, used to detect whether we are configuring
> Index: oafd/ac-corba.c
> ===================================================================
> RCS file: /cvs/gnome/oaf/oafd/ac-corba.c,v
> retrieving revision 1.29
> diff -u -r1.29 ac-corba.c
> --- oafd/ac-corba.c	2000/07/26 01:01:50	1.29
> +++ oafd/ac-corba.c	2000/08/09 05:36:18
> @@ -437,7 +437,8 @@
>  	}
>  
>  	for (num_layers = 0, activatable = server;
> -             activatable && !strcmp (activatable->server_type, "factory") &&
> +             activatable && activatable->server_type &&
> +                     !strcmp (activatable->server_type, "factory") &&
>               num_layers < OAF_LINK_TIME_TO_LIVE; num_layers++) {
>  
>  		activatable = g_hash_table_lookup (child->by_iid, activatable->location_info);

I think this check is unnecessary given the od-load.c change below,
but I guess it's better to code defensively.

> Index: oafd/od-load.c
> ===================================================================
> RCS file: /cvs/gnome/oaf/oafd/od-load.c,v
> retrieving revision 1.16
> diff -u -r1.16 od-load.c
> --- oafd/od-load.c	2000/07/31 04:39:12	1.16
> +++ oafd/od-load.c	2000/08/09 05:36:18
> @@ -159,22 +159,31 @@
>  	}
>  }
>  
> -static gboolean
> -od_validate_iid (const char *iid)
> +static char *
> +od_validate (const char *iid, const char *type, const char *location)
>  {
>          int i;
>  
> +        if (!iid)
> +                return g_strdup (_("a NULL iid is not valid"));
> +
> +        if (!type)
> +                return g_strdup_printf (_("iid %s has a NULL type"), iid);
> +
> +        if (!location)
> +                return g_strdup_printf (_("iid %s has a NULL location"), iid);
> +
>          for (i = 0; iid && iid [i]; i++) {
>                  char c = iid [i];
>  
>                  if (c == ',' || c == '[' || c == ']' ||
>                      /* Reserved for future expansion */
>                      c == '!' || c == '#' || c == '|')
> -                        return FALSE;
> -
> +                        return g_strdup_printf (_("invalid character '%c' in iid '%s'"),
> +                                                c, iid);
>          }
>  
> -        return TRUE;
> +        return NULL;
>  }
>  
>  OAF_ServerInfo *
> @@ -233,7 +242,7 @@
>  			      ? doc->root->childs : doc->root);
>  			     NULL != curnode; curnode = curnode->next) {
>  				OAF_ServerInfo *new_ent;
> -				char *ctmp, *iid;
> +				char *iid, *type, *location, *err;
>                                  gboolean already_there;
>  
>  				if (curnode->type != XML_ELEMENT_NODE)
> @@ -248,11 +257,19 @@
>  					continue;
>  
>  				iid = xmlGetProp (curnode, "iid");
> +                                type = xmlGetProp (curnode, "type");
> +                                location = xmlGetProp (curnode, "location");
>  
> -                                if (!od_validate_iid (iid)) {
> -                                        g_print (_("IID '%s' contains illegal characters; discarding\n"), 
> -                                                 iid);
> -                                        free (iid);
> +                                if ((err = od_validate (iid, type, location))) {
> +                                        g_print ("%s", err);
> +                                        
> +                                        g_free (err);
> +                                        if (iid)
> +                                                xmlFree (iid);
> +                                        if (type)
> +                                                xmlFree (type);
> +                                        if (location)
> +                                                xmlFree (location);
>                                          continue;
>                                  }
>  
> @@ -271,29 +288,25 @@
>                                          memset (new_ent, 0, sizeof (OAF_ServerInfo));
>  
>                                          new_ent->iid = CORBA_string_dup (iid);
> -                                        xmlFree (iid);
>  
> -                                        ctmp = xmlGetProp (curnode, "type");
>                                          new_ent->server_type =
> -                                                CORBA_string_dup (ctmp);
> -                                        free (ctmp);
> +                                                CORBA_string_dup (type);
>  
> -                                        ctmp = xmlGetProp (curnode, "location");
>                                          new_ent->location_info =
> -                                                CORBA_string_dup (ctmp);
> +                                                CORBA_string_dup (location);
>                                          new_ent->hostname = CORBA_string_dup (host);
>                                          new_ent->domain = CORBA_string_dup (domain);
>                                          new_ent->username =
>                                                  CORBA_string_dup (g_get_user_name ());
> -                                        free (ctmp);
>  
>                                          od_entry_read_props (new_ent, curnode);
>                                          
>                                          my_slist_prepend (entries, new_ent);
> -                                } else {
> -                                        xmlFree (iid);
>                                  }
>  
> +                                xmlFree (iid);
> +                                xmlFree (type);
> +                                xmlFree (location);
>  			}
>  
>  			xmlFreeDoc (doc);
> Index: test/Makefile.am
> ===================================================================
> RCS file: /cvs/gnome/oaf/test/Makefile.am,v
> retrieving revision 1.13
> diff -u -r1.13 Makefile.am
> --- test/Makefile.am	2000/07/10 23:51:08	1.13
> +++ test/Makefile.am	2000/08/09 05:36:18
> @@ -21,7 +21,7 @@
>  	@ORBIT_CFLAGS@ @XML_CFLAGS@ @GLIB_CFLAGS@
>  LDADD=../liboaf/liboaf.la @ORBIT_LIBS@ @GLIB_LIBS@
>  
> -oaffiles=empty.oafinfo broken.oafinfo
> +oaffiles=empty.oafinfo
>  
>  emptydatadir=$(datadir)/oaf
>  emptydata_DATA=$(oaffiles)
> @@ -31,6 +31,6 @@
>  oaf-slay: $(srcdir)/oaf-slay.tmpl
>  	sed 's|@oafdir@|'$(pkgdatadir)'|g' < $< > $@
>  
> -EXTRA_DIST=empty.idl oaf-slay.tmpl $(oaffiles)
> +EXTRA_DIST=empty.idl oaf-slay.tmpl $(oaffiles) broken.oafinfo
>  
>  TESTS=oaf-test-client
> Index: test/broken.oafinfo
> ===================================================================
> RCS file: /cvs/gnome/oaf/test/broken.oafinfo,v
> retrieving revision 1.3
> diff -u -r1.3 broken.oafinfo
> --- test/broken.oafinfo	2000/07/24 21:44:22	1.3
> +++ test/broken.oafinfo	2000/08/09 05:36:18
> @@ -9,6 +9,13 @@
>  <oaf_server iid="OAFIID:Broken:20000530" type="exe" location="this-executable-doesnt-exist">
>  </oaf_server>
>  
> +<oaf_server iid="OAFIID:BrokenNoType:20000808">
> +</oaf_server>
> +
> +<oaf_server iid="OAFIID:This#!!%$iid%^$%_|~!OAFIID_ContainsBadChars" type=""
> +location="">
> +</oaf_server>
> +
>  <oaf_server iid="OAFIID:Circular:20000530" type="factory" location="OAFIID:Circular:20000530">
>  </oaf_server>
>  
> Index: test/oaf-test-client.c
> ===================================================================
> RCS file: /cvs/gnome/oaf/test/oaf-test-client.c,v
> retrieving revision 1.10
> diff -u -r1.10 oaf-test-client.c
> --- test/oaf-test-client.c	2000/07/24 21:44:22	1.10
> +++ test/oaf-test-client.c	2000/08/09 05:36:18
> @@ -4,7 +4,7 @@
>  #include <stdlib.h>
>  #include "empty.h"
>  
> -#define TOTAL_TEST_SCORE 11
> +#define TOTAL_TEST_SCORE 13
>  
>  CORBA_Object name_service = CORBA_OBJECT_NIL;
>  
> @@ -188,10 +188,35 @@
>          }
>          fprintf (stderr, "\n");
>  
> +        fprintf (stderr, "Server with IID but no type or location ");
> +        obj = oaf_activate_from_id ("OAFIID:BrokenNoType:20000808", 0, NULL, &ev);
> +        if (ev._major != CORBA_NO_EXCEPTION) {
> +                fprintf (stderr, "failed (except) 1");
> +                CORBA_exception_free (&ev);
> +        } else if (obj) {
> +                fprintf (stderr, "failed (obj) 1");
> +        } else {
> +                fprintf (stderr, "passed 1 ('%s')", oaf_exception_id (&ev));
> +                passed++;
> +        }
> +        if (test_oafd (&ev, "with no-type/loc server")) {
> +                fprintf (stderr, ", passed 2");
> +                passed++;
> +        } else {
> +                fprintf (stderr, ", failed 2");
> +        }
> +        fprintf (stderr, "\n");
>  
> +
>          fprintf (stderr, "\n%d of %d tests passed (%s)\n", passed,
>                   TOTAL_TEST_SCORE,
>                   passed == TOTAL_TEST_SCORE? "All": "some failures");
> +
> +        if (passed < TOTAL_TEST_SCORE * 3 / 2) {
> +                fprintf (stderr, "It looks like you havn't installed broken.oafinfo "
> +                         "into ${prefix}/oaf, this must be done by hand to avoid "
> +                         "redundant warnings.\n");
> +        }
>  
>  	CORBA_exception_free (&ev);
>  
> 
> -- 
>  mmeeks@gnu.org  <><, Pseudo Engineer, itinerant idiot

















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