Dewarningization patch




With the following patch, Bonobo compiles without warnings. Some of
the warnings I fixed were indicative of real bugs - for instance, a
number of places casted off the const from a const CORBA_char * that
got passed to a server implemantation, and later freed it. This is
evil - Sopwith says such strings are not even guaranteed to continue
to be valid after the call to the servant function completes.

There are two possibly controversial changes. One is that I #if 0'd
out functions that were not used. I would have just removed them, but
many of them looked like work in progress that would eventually be
called from elswhere. The second is that I made
bonobo-moniker-client.c #include "libgnorba/gnorba.h". I would have
made it detect if OAF is being used and include the right header as
appropriate, but it does not appear to work with OAF at all right now.

I'd like to add -Werror to the compile flags after applying this patch
(assuming it's approved) to make sure Bonobo remains warning-free. We
have found this discipline very useful for Nautilus development. There
are potential future issues with idl-compiler generated stubs and
skeletons, but the Nautilus hackers are likely to be fixing those as
we go anyway.

BTW, would it be OK if I just commited obvious fixes directly from now
on, instead of posting to the list?  (I'd still ask about anything
major or potentially controversial, of course.)


Here's the patch:


2000-02-07  Maciej Stachowiak  <mjs@eazel.com>

	* bonobo/bonobo-property-bag.c, bonobo/bonobo-property-bag.h,
	bonobo/bonobo-property-types.c, bonobo/bonobo-property-types.h,
	bonobo/bonobo-property.c, bonobo/bonobo-ui-handler.c,
	bonobo/bonobo-ui-handler.h, bonobo/bonobo-view.c,
	components/text-plain/bonobo-text-plain.c, libefs/src/efstool.c,
	libefs/src/simple.c, samples/controls/bonobo-calculator-control.h,
	samples/controls/sample-control-factory.c: Fix a bunch of
	warnings. These fall into the following categories: failing to
	declare a function `static'; inappropriate implicit casts that
	remove `const'; use of `const gpointer' instead of `gconstpointer'
	(not all of these led to warnings but I fixed all I found);
	failure to include needed headers; passing functions with a return
	value where void functions are expected; and unused functions
	(which I #if 0'd out).


Index: bonobo-moniker-client.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-moniker-client.c,v
retrieving revision 1.8
diff -u -r1.8 bonobo-moniker-client.c
--- bonobo-moniker-client.c	2000/01/25 22:04:41	1.8
+++ bonobo-moniker-client.c	2000/02/08 03:05:58
@@ -13,6 +13,7 @@
 #include <bonobo/Bonobo.h>
 #include <bonobo/bonobo-moniker-client.h>
 #include <gtk/gtk.h>
+#include "libgnorba/gnorba.h"
 #include "bonobo-object-directory.h"
 
 /**
Index: bonobo-property-bag-client.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property-bag-client.c,v
retrieving revision 1.4
diff -u -r1.4 bonobo-property-bag-client.c
--- bonobo-property-bag-client.c	2000/01/27 21:08:44	1.4
+++ bonobo-property-bag-client.c	2000/02/08 03:05:58
@@ -817,7 +817,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_boolean ("boolean", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_boolean ("boolean", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -836,7 +836,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_short ("short", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_short ("short", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -855,7 +855,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_ushort ("ushort", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_ushort ("ushort", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -874,7 +874,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_long ("long", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_long ("long", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -893,7 +893,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_ulong ("ulong", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_ulong ("ulong", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -912,7 +912,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_float ("float", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_float ("float", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
@@ -931,7 +931,7 @@
 	g_return_if_fail (BONOBO_IS_PROPERTY_BAG_CLIENT (pbc));
 	g_return_if_fail (propname != NULL);
 
-	any = bonobo_property_marshal_double ("double", (const gpointer) &value, NULL);
+	any = bonobo_property_marshal_double ("double", (gconstpointer) &value, NULL);
 	g_return_if_fail (any != NULL);
 
 	bonobo_property_bag_client_set_value_any (pbc, propname, any);
Index: bonobo-property-bag.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property-bag.c,v
retrieving revision 1.13
diff -u -r1.13 bonobo-property-bag.c
--- bonobo-property-bag.c	2000/01/29 08:26:16	1.13
+++ bonobo-property-bag.c	2000/02/08 03:05:58
@@ -389,7 +389,7 @@
 {
 	PortableServer_ObjectId *oid;
 
-	oid = PortableServer_string_to_ObjectId (name, ev);
+	oid = PortableServer_string_to_ObjectId ((char *) name, ev);
 
 	*obj = (Bonobo_Property) PortableServer_POA_create_reference_with_id (
 		pb->priv->poa, oid, "IDL:Bonobo/Property:1.0", ev);
@@ -908,7 +908,7 @@
 /**
  * bonobo_property_bag_get_value:
  */
-const gpointer
+gconstpointer
 bonobo_property_bag_get_value (BonoboPropertyBag *pb, const char *name)
 {
 	BonoboProperty *prop;
@@ -925,7 +925,7 @@
 /**
  * bonobo_property_bag_get_default:
  */
-const gpointer
+gconstpointer
 bonobo_property_bag_get_default (BonoboPropertyBag *pb, const char *name)
 {
 	BonoboProperty *prop;
@@ -1030,7 +1030,7 @@
  */
 CORBA_any *
 bonobo_property_bag_value_to_any (BonoboPropertyBag *pb, const char *type,
-				  const gpointer value)
+				  gconstpointer value)
 {
 	BonoboPropertyBagValueMarshalerFn  value_marshaler;
 	BonoboPropertyType                *ptype;
Index: bonobo-property-bag.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property-bag.h,v
retrieving revision 1.7
diff -u -r1.7 bonobo-property-bag.h
--- bonobo-property-bag.h	2000/01/25 11:35:45	1.7
+++ bonobo-property-bag.h	2000/02/08 03:05:58
@@ -55,8 +55,8 @@
 							      
 /* Inspecting properties. */
 const char	         *bonobo_property_bag_get_prop_type    (BonoboPropertyBag *pb, const char *name);
-const gpointer	          bonobo_property_bag_get_value        (BonoboPropertyBag *pb, const char *name);
-const gpointer	          bonobo_property_bag_get_default      (BonoboPropertyBag *pb, const char *name);
+gconstpointer	          bonobo_property_bag_get_value        (BonoboPropertyBag *pb, const char *name);
+gconstpointer	          bonobo_property_bag_get_default      (BonoboPropertyBag *pb, const char *name);
 const char	         *bonobo_property_bag_get_docstring    (BonoboPropertyBag *pb, const char *name);
 const BonoboPropertyFlags  bonobo_property_bag_get_flags        (BonoboPropertyBag *pb, const char *name);
 gboolean		  bonobo_property_bag_has_property     (BonoboPropertyBag *pb, const char *name);
@@ -69,7 +69,7 @@
  * Mainly used by BonoboProperty for marshaling and demarshaling
  * property values across CORBA.
  */
-typedef CORBA_any *(*BonoboPropertyBagValueMarshalerFn)	      (const char *type, const gpointer value,
+typedef CORBA_any *(*BonoboPropertyBagValueMarshalerFn)	      (const char *type, gconstpointer value,
 							       gpointer user_data);
 typedef gpointer   (*BonoboPropertyBagValueDemarshalerFn)      (const char *type, const CORBA_any *any,
 							       gpointer user_data);
@@ -85,7 +85,7 @@
 							       BonoboPropertyBagValueReleaserFn    releaser,
 							       gpointer user_data);
 CORBA_any		 *bonobo_property_bag_value_to_any     (BonoboPropertyBag *pb, const char *type,
-							       const gpointer value);
+							       gconstpointer value);
 gpointer		  bonobo_property_bag_any_to_value     (BonoboPropertyBag *pb, const char *type,
 							       const CORBA_any *any);
 gboolean		  bonobo_property_bag_compare_values   (BonoboPropertyBag *pb, const char *type,
Index: bonobo-property-types.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property-types.c,v
retrieving revision 1.2
diff -u -r1.2 bonobo-property-types.c
--- bonobo-property-types.c	2000/01/25 11:35:45	1.2
+++ bonobo-property-types.c	2000/02/08 03:05:58
@@ -29,7 +29,7 @@
  * Standard type marshalers.
  */
 CORBA_any *
-bonobo_property_marshal_boolean (const char *type, const gpointer value,
+bonobo_property_marshal_boolean (const char *type, gconstpointer value,
 				gpointer user_data)
 {
 	CORBA_any *any;
@@ -50,7 +50,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_string (const char *type, const gpointer value,
+bonobo_property_marshal_string (const char *type, gconstpointer value,
 			       gpointer user_data)
 {
 	CORBA_any *any;
@@ -74,7 +74,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_short (const char *type, const gpointer value,
+bonobo_property_marshal_short (const char *type, gconstpointer value,
 			      gpointer user_data)
 {
 	CORBA_any *any;
@@ -94,7 +94,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_ushort (const char *type, const gpointer value,
+bonobo_property_marshal_ushort (const char *type, gconstpointer value,
 			       gpointer user_data)
 {
 	CORBA_any *any;
@@ -115,7 +115,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_long (const char *type, const gpointer value,
+bonobo_property_marshal_long (const char *type, gconstpointer value,
 			     gpointer user_data)
 {
 	CORBA_any *any;
@@ -136,7 +136,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_ulong (const char *type, const gpointer value,
+bonobo_property_marshal_ulong (const char *type, gconstpointer value,
 			      gpointer user_data)
 {
 	CORBA_any *any;
@@ -157,7 +157,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_float (const char *type, const gpointer value,
+bonobo_property_marshal_float (const char *type, gconstpointer value,
 			      gpointer user_data)
 {
 	CORBA_any *any;
@@ -178,7 +178,7 @@
 }
 
 CORBA_any *
-bonobo_property_marshal_double (const char *type, const gpointer value,
+bonobo_property_marshal_double (const char *type, gconstpointer value,
 			       gpointer user_data)
 {
 	CORBA_any *any;
Index: bonobo-property-types.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property-types.h,v
retrieving revision 1.3
diff -u -r1.3 bonobo-property-types.h
--- bonobo-property-types.h	2000/01/27 21:08:44	1.3
+++ bonobo-property-types.h	2000/02/08 03:05:58
@@ -8,21 +8,21 @@
 /*
  * Standard type marshaler.
  */
-CORBA_any *bonobo_property_marshal_boolean   (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_boolean   (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_string    (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_string    (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_short     (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_short     (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_ushort    (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_ushort    (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_long	     (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_long	     (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_ulong     (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_ulong     (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_float     (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_float     (const char *type, gconstpointer value,
 					      gpointer user_data);
-CORBA_any *bonobo_property_marshal_double    (const char *type, const gpointer value,
+CORBA_any *bonobo_property_marshal_double    (const char *type, gconstpointer value,
 					      gpointer user_data);
 
 /*
Index: bonobo-property.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-property.c,v
retrieving revision 1.5
diff -u -r1.5 bonobo-property.c
--- bonobo-property.c	2000/01/25 11:35:45	1.5
+++ bonobo-property.c	2000/02/08 03:05:58
@@ -35,7 +35,7 @@
 	CORBA_TypeCode tc;
 	const char *type;
 	CORBA_any *any;
-	gpointer value;
+	gconstpointer value;
 
 	value = bonobo_property_bag_get_value (pservant->pb, pservant->property_name);
 	type  = bonobo_property_bag_get_prop_type (pservant->pb, pservant->property_name);
@@ -55,7 +55,7 @@
 {
 	BonoboPropertyServant *pservant = (BonoboPropertyServant *) servant;
 	const char *type;
-	gpointer value;
+	gconstpointer value;
 
 	type = bonobo_property_bag_get_prop_type (pservant->pb, pservant->property_name);
 	value = bonobo_property_bag_get_value (pservant->pb, pservant->property_name);
@@ -83,7 +83,7 @@
 				 CORBA_Environment *ev)
 {
 	BonoboPropertyServant *pservant = (BonoboPropertyServant *) servant;
-	gpointer default_value;
+	gconstpointer default_value;
 	const char *type;
 
 	type = bonobo_property_bag_get_prop_type (pservant->pb, pservant->property_name);
Index: bonobo-ui-handler.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-handler.c,v
retrieving revision 1.48
diff -u -r1.48 bonobo-ui-handler.c
--- bonobo-ui-handler.c	2000/01/29 18:36:33	1.48
+++ bonobo-ui-handler.c	2000/02/08 03:06:00
@@ -1145,6 +1145,7 @@
 	return final;
 }
 
+#if 0
 /*
  * This helper function replaces all instances of "\/" with "/"
  * and all instances of "\\" with "\".
@@ -1179,6 +1180,7 @@
 	g_free (new);
 	return final;
 }
+#endif
 
 /*
  * The path-building routine.
@@ -1749,10 +1751,10 @@
 	BonoboUIHandlerMenuItem *item;
 
 	item = g_new0 (BonoboUIHandlerMenuItem, 1);
-	item->path        = path;
+	item->path        = strdup (path);
 	item->type        = type;
-	item->label       = label;
-	item->hint        = hint;
+	item->label       = strdup (label);
+	item->hint        = strdup (hint);
 	item->pos         = pos;
 	item->pixmap_type = pixmap_type;
 	item->pixmap_data = pixmap_data;
@@ -4710,6 +4712,7 @@
 	menu_remote_attribute_data_set (uih, path, attrs);
 }
 
+#if 0
 static void
 toolbar_item_remote_set_hint (BonoboUIHandler *uih, const char *path,
 			      const char *hint)
@@ -4723,6 +4726,7 @@
 	attrs->hint = CORBA_string_dup (CORBIFY_STRING (hint));
 	toolbar_item_remote_attribute_data_set (uih, path, attrs);
 }
+#endif
 
 /**
  * bonobo_ui_handler_menu_set_hint:
@@ -5012,6 +5016,7 @@
 	menu_remote_attribute_data_set (uih, path, attrs);
 }
 
+#if 0
 static void
 toolbar_item_remote_set_accel (BonoboUIHandler *uih, const char *path,
 			       guint accelerator_key, GdkModifierType ac_mods)
@@ -5025,6 +5030,7 @@
 	attrs->ac_mods = ac_mods;
 	toolbar_item_remote_attribute_data_set (uih, path, attrs);
 }
+#endif
 
 /**
  * bonobo_ui_handler_menu_set_accel:
@@ -5076,6 +5082,7 @@
 	ui_remote_attribute_data_free (attrs);
 }
 
+#if 0
 static void
 toolbar_item_remote_get_accel (BonoboUIHandler *uih, const char *path,
 			       guint *accelerator_key, GdkModifierType *ac_mods)
@@ -5093,6 +5100,7 @@
 
 	ui_remote_attribute_data_free (attrs);
 }
+#endif
 
 /**
  * bonobo_ui_handler_menu_get_accel:
@@ -5229,6 +5237,7 @@
 	menu_remote_attribute_data_set (uih, path, attrs);
 }
 
+#if 0
 static void
 toolbar_item_remote_set_toggle_state (BonoboUIHandler *uih, const char *path,
 				      gboolean state)
@@ -5241,6 +5250,7 @@
 	attrs->toggle_state = state;
 	toolbar_item_remote_attribute_data_set (uih, path, attrs);
 }
+#endif
 
 /**
  * bonobo_ui_handler_menu_set_toggle_state:
@@ -5331,12 +5341,14 @@
 	menu_remote_set_toggle_state (uih, path, state);
 }
 
+#if 0
 static void
 toolbar_item_remote_set_radio_state (BonoboUIHandler *uih, const char *path,
 				     gboolean state)
 {
 	toolbar_item_remote_set_toggle_state (uih, path, state);
 }
+#endif
 
 /**
  * bonobo_ui_handler_menu_set_radio_state:
@@ -5487,7 +5499,7 @@
 		   const char *label, const char *hint, int pos,
 		   const Bonobo_Control control,
 		   BonoboUIHandlerPixmapType pixmap_type,
-		   gconstpointer pixmap_data, guint accelerator_key,
+		   gpointer pixmap_data, guint accelerator_key,
 		   GdkModifierType ac_mods,
 		   BonoboUIHandlerCallbackFunc callback,
 		   gpointer callback_data)
@@ -5496,10 +5508,10 @@
 
 	item = g_new0 (BonoboUIHandlerToolbarItem, 1);
 
-	item->path = path;
+	item->path = strdup (path);
 	item->type = type;
-	item->label = label;
-	item->hint = hint;
+	item->label = strdup (label);
+	item->hint = strdup (hint);
 	item->pos = pos;
 	item->control = control;
 	item->pixmap_type = pixmap_type;
@@ -6854,7 +6866,7 @@
 			      const char *label, const char *hint,
 			      int pos, const Bonobo_Control control,
 			      BonoboUIHandlerPixmapType pixmap_type,
-			      gconstpointer pixmap_data, guint accelerator_key,
+			      gpointer pixmap_data, guint accelerator_key,
 			      GdkModifierType ac_mods,
 			      BonoboUIHandlerCallbackFunc callback,
 			      gpointer callback_data)
@@ -6885,7 +6897,7 @@
 bonobo_ui_handler_toolbar_new_item (BonoboUIHandler *uih, const char *path,
 				   const char *label, const char *hint, int pos,
 				   BonoboUIHandlerPixmapType pixmap_type,
-				   gconstpointer pixmap_data,
+				   gpointer pixmap_data,
 				   guint accelerator_key, GdkModifierType ac_mods,
 				   BonoboUIHandlerCallbackFunc callback,
 				   gpointer callback_data)
@@ -7235,7 +7247,8 @@
 				     ex_Bonobo_UIHandler_PathNotFound, NULL);
 		return;
 	}
-	toolbar_toplevel_remove_item_internal (uih, containee_uih);
+
+	toolbar_toplevel_remove_item_internal (uih, internal);
 }
 
 /**
Index: bonobo-ui-handler.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-handler.h,v
retrieving revision 1.32
diff -u -r1.32 bonobo-ui-handler.h
--- bonobo-ui-handler.h	2000/01/29 11:02:32	1.32
+++ bonobo-ui-handler.h	2000/02/08 03:06:00
@@ -402,7 +402,7 @@
 									 const char *label, const char *hint,
 									 int pos, const Bonobo_Control control,
 									 BonoboUIHandlerPixmapType pixmap_type,
-									 gconstpointer pixmap_data, guint accelerator_key,
+									 gpointer pixmap_data, guint accelerator_key,
 									 GdkModifierType ac_mods,
 									 BonoboUIHandlerCallbackFunc callback,
 									 gpointer callback_data);
@@ -411,7 +411,7 @@
 void				 bonobo_ui_handler_toolbar_new_item	(BonoboUIHandler *uih, const char *path,
 									 const char *label, const char *hint, int pos,
 									 BonoboUIHandlerPixmapType pixmap_type,
-									 gconstpointer pixmap_data,
+									 gpointer pixmap_data,
 									 guint accelerator_key, GdkModifierType ac_mods,
 									 BonoboUIHandlerCallbackFunc callback,
 									 gpointer callback_data);
Index: bonobo-view.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-view.c,v
retrieving revision 1.56
diff -u -r1.56 bonobo-view.c
--- bonobo-view.c	2000/01/25 11:35:46	1.56
+++ bonobo-view.c	2000/02/08 03:06:00
@@ -93,6 +93,7 @@
 	return (Bonobo_View) bonobo_object_activate_servant (object, servant);
 }
 
+#if 0
 /**
  * bonobo_view_activate:
  * @view: 
@@ -107,6 +108,7 @@
 {
 	bonobo_view_activate_notify (view, activate);
 }
+#endif
 
 /**
  * bonobo_view_construct:



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