From: Matthew Barnes Date: Sat, 22 May 2010 00:06:12 +0000 (-0400) Subject: Add argument checks to camel-partition-table.c. X-Git-Tag: upstream/3.7.4~3073 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c2f5b48fd2e76892f605e92bd1038b431c804a5;p=platform%2Fupstream%2Fevolution-data-server.git Add argument checks to camel-partition-table.c. --- diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c index daa9e7e..b4f34d3 100644 --- a/camel/camel-partition-table.c +++ b/camel/camel-partition-table.c @@ -177,7 +177,7 @@ static CamelBlock *find_partition (CamelPartitionTable *cpi, camel_hash_t id, gi } CamelPartitionTable * -camel_partition_table_new (struct _CamelBlockFile *bs, +camel_partition_table_new (CamelBlockFile *bs, camel_block_t root) { CamelPartitionTable *cpi; @@ -185,6 +185,8 @@ camel_partition_table_new (struct _CamelBlockFile *bs, CamelPartitionKeyBlock *kb; CamelBlock *block, *pblock; + g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), NULL); + cpi = g_object_new (CAMEL_TYPE_PARTITION_TABLE, NULL); cpi->rootid = root; cpi->blocks = g_object_ref (bs); @@ -238,6 +240,8 @@ camel_partition_table_sync (CamelPartitionTable *cpi) CamelBlock *bl, *bn; gint ret = 0; + g_return_val_if_fail (CAMEL_IS_PARTITION_TABLE (cpi), -1); + CAMEL_PARTITION_TABLE_LOCK (cpi, lock); if (cpi->blocks) { @@ -268,6 +272,9 @@ camel_partition_table_lookup (CamelPartitionTable *cpi, camel_key_t keyid = 0; gint index, i; + g_return_val_if_fail (CAMEL_IS_PARTITION_TABLE (cpi), 0); + g_return_val_if_fail (key != NULL, 0); + hashid = hash_key (key); CAMEL_PARTITION_TABLE_LOCK (cpi, lock); @@ -314,6 +321,9 @@ camel_partition_table_remove (CamelPartitionTable *cpi, camel_hash_t hashid; gint index, i; + g_return_val_if_fail (CAMEL_IS_PARTITION_TABLE (cpi), FALSE); + g_return_val_if_fail (key != NULL, FALSE); + hashid = hash_key (key); CAMEL_PARTITION_TABLE_LOCK (cpi, lock); @@ -381,9 +391,12 @@ camel_partition_table_add (CamelPartitionTable *cpi, CamelPartitionKeyBlock *kb, *newkb, *nkb = NULL, *pkb = NULL; CamelBlock *block, *ptblock, *ptnblock; gint i, half, len; - struct _CamelPartitionKey keys[CAMEL_BLOCK_SIZE/4]; + CamelPartitionKey keys[CAMEL_BLOCK_SIZE/4]; gint ret = -1; + g_return_val_if_fail (CAMEL_IS_PARTITION_TABLE (cpi), -1); + g_return_val_if_fail (key != NULL, -1); + hashid = hash_key(key); CAMEL_PARTITION_TABLE_LOCK (cpi, lock); @@ -643,6 +656,8 @@ camel_key_table_new (CamelBlockFile *bs, { CamelKeyTable *ki; + g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), NULL); + ki = g_object_new (CAMEL_TYPE_KEY_TABLE, NULL); ki->blocks = g_object_ref (bs); @@ -666,6 +681,8 @@ camel_key_table_new (CamelBlockFile *bs, gint camel_key_table_sync (CamelKeyTable *ki) { + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), -1); + #ifdef SYNC_UPDATES return 0; #else @@ -685,6 +702,9 @@ camel_key_table_add (CamelKeyTable *ki, guint offset; camel_key_t keyid = 0; + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), 0); + g_return_val_if_fail (key != NULL, 0); + /* Maximum key size = 128 chars */ len = strlen (key); if (len > CAMEL_KEY_TABLE_MAX_KEY) @@ -781,6 +801,7 @@ camel_key_table_set_data (CamelKeyTable *ki, gint index; CamelKeyBlock *kb; + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), FALSE); g_return_val_if_fail (keyid != 0, FALSE); blockid = keyid & (~(CAMEL_BLOCK_SIZE-1)); @@ -817,6 +838,7 @@ camel_key_table_set_flags (CamelKeyTable *ki, CamelKeyBlock *kb; guint old; + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), FALSE); g_return_val_if_fail (keyid != 0, FALSE); blockid = keyid & (~(CAMEL_BLOCK_SIZE-1)); @@ -859,6 +881,7 @@ camel_key_table_lookup (CamelKeyTable *ki, gchar *key; CamelKeyBlock *kb; + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), 0); g_return_val_if_fail (keyid != 0, 0); if (keyp) @@ -913,6 +936,8 @@ camel_key_table_next(CamelKeyTable *ki, camel_key_t next, gchar **keyp, guint *f camel_block_t blockid; gint index; + g_return_val_if_fail (CAMEL_IS_KEY_TABLE (ki), 0); + if (keyp) *keyp = NULL; if (flagsp)