gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (733e5b784 -> 0fa8b5ac5)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (733e5b784 -> 0fa8b5ac5)
Date: Mon, 13 Mar 2017 18:11:02 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 733e5b784 clarify
     new ca097ea47 fix theoretical leak in test
     new d012e0579 check unlink() return value in test
     new 7898eb1be check sqlite3_close() return value in test
     new 0fa8b5ac5 check multihashmap32_put return value in mq.c

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/datacache/plugin_datacache_sqlite.c |  3 +-
 src/sq/test_sq.c                        | 17 +++++---
 src/util/mq.c                           | 24 +++++++++--
 src/util/test_common_allocation.c       | 73 +++++++++++++++++++--------------
 4 files changed, 76 insertions(+), 41 deletions(-)

diff --git a/src/datacache/plugin_datacache_sqlite.c 
b/src/datacache/plugin_datacache_sqlite.c
index 5cc48b26c..dd79d0125 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -758,7 +758,8 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sq_prepare");
-    (void) sqlite3_close (plugin->dbh);
+    GNUNET_break (SQLITE_OK ==
+                  sqlite3_close (plugin->dbh));
     GNUNET_free (plugin);
     return NULL;
   }
diff --git a/src/sq/test_sq.c b/src/sq/test_sq.c
index e6896861e..6387eda31 100644
--- a/src/sq/test_sq.c
+++ b/src/sq/test_sq.c
@@ -254,7 +254,10 @@ main(int argc,
     fprintf (stderr,
             "Failed to create table\n");
     sqlite3_close (dbh);
-    unlink ("test.db");
+    if (0 != unlink ("test.db"))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+                                "unlink",
+                                "test.db");
     return 1;
   }
 
@@ -266,12 +269,14 @@ main(int argc,
   {
     fprintf (stderr,
             "Failed to drop table\n");
-    sqlite3_close (dbh);
-    unlink ("test.db");
-    return 1;
+    ret = 1;
   }
-  sqlite3_close (dbh);
-  unlink ("test.db");
+  GNUNET_break (SQLITE_OK ==
+                sqlite3_close (dbh));
+  if (0 != unlink ("test.db"))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+                              "unlink",
+                              "test.db");
   return ret;
 }
 
diff --git a/src/util/mq.c b/src/util/mq.c
index 79e2d0455..25cf24e11 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -811,22 +811,40 @@ GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq,
     mq->assoc_id = 1;
   }
   id = mq->assoc_id++;
-  GNUNET_CONTAINER_multihashmap32_put (mq->assoc_map, id, assoc_data,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CONTAINER_multihashmap32_put (mq->assoc_map,
+                                                      id,
+                                                      assoc_data,
+                                                      
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   return id;
 }
 
 
+/**
+ * Get the data associated with a @a request_id in a queue
+ *
+ * @param mq the message queue with the association
+ * @param request_id the request id we are interested in
+ * @return the associated data
+ */
 void *
 GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq,
                      uint32_t request_id)
 {
   if (NULL == mq->assoc_map)
     return NULL;
-  return GNUNET_CONTAINER_multihashmap32_get (mq->assoc_map, request_id);
+  return GNUNET_CONTAINER_multihashmap32_get (mq->assoc_map,
+                                              request_id);
 }
 
 
+/**
+ * Remove the association for a @a request_id
+ *
+ * @param mq the message queue with the association
+ * @param request_id the request id we want to remove
+ * @return the associated data
+ */
 void *
 GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq,
                         uint32_t request_id)
diff --git a/src/util/test_common_allocation.c 
b/src/util/test_common_allocation.c
index 4ef98b629..4d1b6fe7d 100644
--- a/src/util/test_common_allocation.c
+++ b/src/util/test_common_allocation.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001, 2002, 2003, 2005, 2006 GNUnet e.V.
+     Copyright (C) 2001, 2002, 2003, 2005, 2006, 2017 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -25,6 +25,7 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
+
 static int
 check ()
 {
@@ -95,47 +96,57 @@ check ()
   if (ptrs[0] != NULL)
     return 9;
 
-       /* GNUNET_new_array_2d tests */
-       a2 = GNUNET_new_array_2d (17, 22, unsigned int);
-       for (i = 0; i < 17; i++)
-       {
-               for (j = 0; j < 22; j++)
-               {
-                       if (0 != a2[i][j])
-                               return 10;
-                       a2[i][j] = i * 100 + j;
-               }
-       }
-       free (a2);
-
-       /* GNUNET_new_array_3d tests */
-       a3 = GNUNET_new_array_3d (2, 3, 4, char);
-       for (i = 0; i < 2; i++)
-       {
-               for (j = 0; j < 3; j++)
-               {
-                       for (k = 0; k < 4; k++)
-                       {
-                               if (0 != a3[i][j][k])
-                                       return 11;
-                               a3[i][j][k] = i * 100 + j * 10 + k;
-                       }
-               }
-       }
-       free (a3);
+  /* GNUNET_new_array_2d tests */
+  a2 = GNUNET_new_array_2d (17, 22, unsigned int);
+  for (i = 0; i < 17; i++)
+  {
+    for (j = 0; j < 22; j++)
+    {
+      if (0 != a2[i][j])
+      {
+        GNUNET_free (a2);
+        return 10;
+      }
+      a2[i][j] = i * 100 + j;
+    }
+  }
+  GNUNET_free (a2);
 
+  /* GNUNET_new_array_3d tests */
+  a3 = GNUNET_new_array_3d (2, 3, 4, char);
+  for (i = 0; i < 2; i++)
+  {
+    for (j = 0; j < 3; j++)
+    {
+      for (k = 0; k < 4; k++)
+      {
+        if (0 != a3[i][j][k])
+        {
+          GNUNET_free (a3);
+          return 11;
+        }
+        a3[i][j][k] = i * 100 + j * 10 + k;
+      }
+    }
+  }
+  GNUNET_free (a3);
   return 0;
 }
 
+
 int
 main (int argc, char *argv[])
 {
   int ret;
 
-  GNUNET_log_setup ("test-common-allocation", "WARNING", NULL);
+  GNUNET_log_setup ("test-common-allocation",
+                    "WARNING",
+                    NULL);
   ret = check ();
   if (ret != 0)
-    FPRINTF (stderr, "ERROR %d.\n", ret);
+    FPRINTF (stderr,
+             "ERROR %d.\n",
+             ret);
   return ret;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]