for (uint32_t i = 0; i < 256; i++)
{
char push_recv_str_tmp[8];
- (void) snprintf (push_recv_str_tmp, 8, "%" PRIu32 "\n", sub->push_recv[i]);
+
+ GNUNET_snprintf (push_recv_str_tmp,
+ sizeof (push_recv_str_tmp),
+ "%" PRIu32 "\n",
+ sub->push_recv[i]);
(void) strncat (push_recv_str,
push_recv_str_tmp,
1535 - strnlen (push_recv_str, 1536));
(void) strncat (push_recv_str,
"\n",
1535 - strnlen (push_recv_str, 1536));
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing push stats to disk\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Writing push stats to disk\n");
to_file_w_len (sub->file_name_push_recv, 1535, push_recv_str);
GNUNET_free (sub->file_name_push_recv);
sub->file_name_push_recv = NULL;
for (uint32_t i = 0; i < 256; i++)
{
char pull_delays_str_tmp[8];
- (void) snprintf (pull_delays_str_tmp, 8, "%" PRIu32 "\n", sub->pull_delays[i]);
+
+ GNUNET_snprintf (pull_delays_str_tmp,
+ sizeof (pull_delays_str_tmp),
+ "%" PRIu32 "\n",
+ sub->pull_delays[i]);
(void) strncat (pull_delays_str,
pull_delays_str_tmp,
1535 - strnlen (pull_delays_str, 1536));
(void) cls;
(void) mq;
- GNUNET_CONTAINER_multipeermap_put (map_single_hop, peer, NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_put (map_single_hop,
+ peer,
+ NULL,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
return NULL;
}
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;
}