summaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-02-21 11:58:05 +0100
committerChristian Grothoff <christian@grothoff.org>2019-02-21 11:58:05 +0100
commitebaa4fac0cfc3ae3a00140474c38b1e0b3b53178 (patch)
tree55d83f9540510c30980673325e8e517091e8c75a /src/rps/rps-test_util.c
parentd58328bbdf7924f8ea74fbdf23d4972c8b7b4d46 (diff)
fix uninit issue: bad use of hash map
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r--src/rps/rps-test_util.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 3a482c1e6..85829f247 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -74,49 +74,42 @@ static struct GNUNET_CONTAINER_MultiHashMap *open_files;
struct GNUNET_DISK_FileHandle *
get_file_handle (const char *name)
{
- struct GNUNET_HashCode hash = {0};
+ struct GNUNET_HashCode hash;
struct GNUNET_DISK_FileHandle *fh;
if (NULL == open_files)
{
open_files = GNUNET_CONTAINER_multihashmap_create (16,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Created map of open files.\n");
}
GNUNET_CRYPTO_hash (name,
- strnlen (name,
- 512),
+ strlen (name),
&hash);
- if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (open_files,
- &hash))
- {
- fh = GNUNET_DISK_file_open (name,
- GNUNET_DISK_OPEN_WRITE |
- GNUNET_DISK_OPEN_CREATE |
- GNUNET_DISK_OPEN_APPEND,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE |
- GNUNET_DISK_PERM_GROUP_READ);
- if (NULL == fh)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Opening file `%s' failed.\n",
- name);
- GNUNET_assert (0);
- }
- GNUNET_CONTAINER_multihashmap_put (open_files,
- &hash,
- fh,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ if (NULL != (fh = GNUNET_CONTAINER_multihashmap_get (open_files,
+ &hash)))
return fh;
- }
- else
+ fh = GNUNET_DISK_file_open (name,
+ GNUNET_DISK_OPEN_WRITE |
+ GNUNET_DISK_OPEN_CREATE |
+ GNUNET_DISK_OPEN_APPEND,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE |
+ GNUNET_DISK_PERM_GROUP_READ);
+ if (NULL == fh)
{
- fh = GNUNET_CONTAINER_multihashmap_get (open_files,
- &hash);
- return fh;
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Opening file `%s' failed.\n",
+ name);
+ GNUNET_assert (0);
}
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_put (open_files,
+ &hash,
+ fh,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ return fh;
}