[asterisk-commits] russell: branch rizzo/astobj2 r79559 - /team/rizzo/astobj2/main/astobj2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 15 10:05:21 CDT 2007


Author: russell
Date: Wed Aug 15 10:05:21 2007
New Revision: 79559

URL: http://svn.digium.com/view/asterisk?view=rev&rev=79559
Log:
Make some changes so that this will build on my 64-bit machine in dev-mode.
 * The magic number in the internal ao2 data is now just the AO2_MAGIC number
   instead of that XOR'd with the pointer value.  Casting the pointer to a
   uint32_t on a 64-bit machine causes a warning as they are not the same size.
 * Change the version field to a signed int to avoid casting to the atomic int
   functions.  This resolves some pointer signedness warnings.
 * Change the uses of ao2_callback for print_cb to pass the address to the fd
   instead of the fd casted to a pointer and then back to an int later.  The
   casting causes warnings as pointers and ints aren't the same size on my
   64-bit machine.

Modified:
    team/rizzo/astobj2/main/astobj2.c

Modified: team/rizzo/astobj2/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/astobj2.c?view=diff&rev=79559&r1=79558&r2=79559
==============================================================================
--- team/rizzo/astobj2/main/astobj2.c (original)
+++ team/rizzo/astobj2/main/astobj2.c Wed Aug 15 10:05:21 2007
@@ -101,7 +101,7 @@
 		assert(user_data != NULL);\
 	}\
 	p = (struct astobj2 *)((char *)(user_data) - sizeof(struct astobj2));\
-	if (AO2_MAGIC != (p->priv_data.magic ^ (uint32_t)p) ) {\
+	if (AO2_MAGIC != (p->priv_data.magic) ) {\
 		ast_verbose("----!!!!!--------- bad magic number 0x%x for %p\n", p->priv_data.magic, p);\
 		p = NULL;\
 	}\
@@ -203,7 +203,7 @@
 
 	/* init */
 	ast_mutex_init(&obj->priv_data.lock);
-	obj->priv_data.magic = AO2_MAGIC ^ (uint32_t)(obj);
+	obj->priv_data.magic = AO2_MAGIC;
 	obj->priv_data.data_size = data_size;
 	obj->priv_data.ref_counter = 1;
 	obj->priv_data.destructor_fn = destructor_fn;	/* can be NULL */
@@ -251,7 +251,7 @@
         ao2_callback_fn cmp_fn;
         int     n_buckets;
         int     elements;       /* number of elements in the container */
-	uint version;		/* please read above */
+	int version;		/* please read above */
         struct bucket buckets[0]; /* variable size */
 };
  
@@ -305,7 +305,7 @@
  */
 struct bucket_list {
 	struct bucket_list *next;	/* pointer to next bucket_list */
-	uint version;
+	int version;
 	struct astobj2 *astobj;		/* pointer to internal data */
 }; 
 
@@ -587,10 +587,10 @@
 
 static int print_cb(void *obj, void *arg, int flag)
 {
-	int fd = (int)arg;
+	int *fd = arg;
 	char *s = (char *)obj;
 
-	ast_cli(fd, "string <%s>\n", s);
+	ast_cli(*fd, "string <%s>\n", s);
 	return 0;
 }
 
@@ -646,7 +646,7 @@
 		ao2_link(c1, obj);
 	}
 	ast_cli(fd, "testing callbacks\n");
-	ao2_callback(c1, 0, print_cb, (void *)fd);
+	ao2_callback(c1, 0, print_cb, &fd);
 
 	ast_cli(fd, "testing iterators, remove every second object\n");
 	{
@@ -668,7 +668,7 @@
 		}
 	}
 	ast_cli(fd, "testing callbacks again\n");
-	ao2_callback(c1, 0, print_cb, (void*)fd);
+	ao2_callback(c1, 0, print_cb, &fd);
 
 	ast_verbose("now you should see an error message:\n");
 	ao2_ref(&i, -1);	/* i is not a valid object so we print an error here */




More information about the asterisk-commits mailing list