- fix use of uninitialized memory
[oweals/gnunet.git] / src / namecache / plugin_namecache_sqlite.c
index 7eb8b4503e44980bd5ec44fb81ea444ac2ad11fc..cd89f4b337aa272f85141d92a8779d9dd9273d47 100644 (file)
@@ -1,6 +1,6 @@
  /*
   * This file is part of GNUnet
-  * (C) 2009-2013 Christian Grothoff (and other contributing authors)
+  * Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
   *
   * GNUnet is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
   *
   * You should have received a copy of the GNU General Public License
   * along with GNUnet; see the file COPYING.  If not, write to the
-  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-  * Boston, MA 02111-1307, USA.
+  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
   */
 
 /**
@@ -145,7 +145,7 @@ create_indices (sqlite3 * dbh)
 #else
 #define ENULL &e
 #define ENULL_DEFINED 1
-#define CHECK(a) if (! a) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", e); sqlite3_free(e); }
+#define CHECK(a) if (! (a)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", e); sqlite3_free(e); }
 #endif
 
 
@@ -212,9 +212,6 @@ database_setup (struct Plugin *plugin)
   CHECK (SQLITE_OK ==
          sqlite3_exec (plugin->dbh, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
                        ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh, "PRAGMA count_changes=OFF", NULL, NULL,
-                       ENULL));
   CHECK (SQLITE_OK ==
          sqlite3_exec (plugin->dbh, "PRAGMA page_size=4092", NULL, NULL,
                        ENULL));
@@ -366,7 +363,7 @@ namecache_sqlite_expire_blocks (struct Plugin *plugin)
  */
 static int
 namecache_sqlite_cache_block (void *cls,
-                             const struct GNUNET_NAMESTORE_Block *block)
+                             const struct GNUNET_GNSRECORD_Block *block)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_HashCode query;
@@ -495,7 +492,7 @@ namecache_sqlite_lookup_block (void *cls,
   int ret;
   int sret;
   size_t block_size;
-  const struct GNUNET_NAMESTORE_Block *block;
+  const struct GNUNET_GNSRECORD_Block *block;
 
   if (SQLITE_OK != sqlite3_bind_blob (plugin->lookup_block, 1,
                                      query, sizeof (struct GNUNET_HashCode),
@@ -514,7 +511,7 @@ namecache_sqlite_lookup_block (void *cls,
   {
     block = sqlite3_column_blob (plugin->lookup_block, 0);
     block_size = sqlite3_column_bytes (plugin->lookup_block, 0);
-    if ( (block_size < sizeof (struct GNUNET_NAMESTORE_Block)) ||
+    if ( (block_size < sizeof (struct GNUNET_GNSRECORD_Block)) ||
         (ntohl (block->purpose.size) +
          sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
          sizeof (struct GNUNET_CRYPTO_EcdsaSignature) != block_size) )