[Zodb-checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.53

Tim Peters tim.one at comcast.net
Wed Apr 16 13:01:10 EDT 2003


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv20433/lib/python/BTrees

Modified Files:
	BucketTemplate.c 
Log Message:
bucket_set():  Backported Guido's fix to squash nuisance warnings from gcc.


=== Zope/lib/python/BTrees/BucketTemplate.c 1.52 => 1.53 ===
--- Zope/lib/python/BTrees/BucketTemplate.c:1.52	Fri Apr 11 15:38:18 2003
+++ Zope/lib/python/BTrees/BucketTemplate.c	Wed Apr 16 12:01:10 2003
@@ -299,7 +299,18 @@
 {
     int i, cmp;
     KEY_TYPE key;
-    VALUE_TYPE value;
+
+    /* Subtle:  there may or may not be a value.  If there is, we need to
+     * check its type early, so that in case of error we can get out before
+     * mutating the bucket.  But because value isn't used on all paths, if
+     * we don't initialize value then gcc gives a nuisance complaint that
+     * value may be used initialized (it can't be, but gcc doesn't know
+     * that).  So we initialize it.  However, VALUE_TYPE can be various types,
+     * including int, PyObject*, and char[6], so it's a puzzle to spell
+     * initialization.  It so happens that {0} is a valid initializer for all
+     * these types.
+     */
+    VALUE_TYPE value = {0};	/* squash nuisance warning */
     int result = -1;    /* until proven innocent */
     int copied = 1;
 




More information about the Zodb-checkins mailing list