aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-10-31 18:20:05 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-10-31 18:20:05 +0100
commit5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e (patch)
treece4d162423553bc5bdc1a085b7fca9a9ad811e27
parentaa9014fd46c64142fb087d7a7288f5347532e2fe (diff)
downloadlibgnunetchat-5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e.tar.gz
libgnunetchat-5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e.zip
Added assertions to ensure code safety
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/gnunet_chat_contact.c4
-rw-r--r--src/gnunet_chat_context.c16
-rw-r--r--src/gnunet_chat_context_intern.c6
-rw-r--r--src/gnunet_chat_file.c23
-rw-r--r--src/gnunet_chat_group.c13
-rw-r--r--src/gnunet_chat_group_intern.c7
-rw-r--r--src/gnunet_chat_handle.c8
-rw-r--r--src/gnunet_chat_handle_intern.c46
-rw-r--r--src/gnunet_chat_invitation.c4
-rw-r--r--src/gnunet_chat_lib_intern.c17
-rw-r--r--src/gnunet_chat_message.c6
-rw-r--r--src/gnunet_chat_util.c18
12 files changed, 164 insertions, 4 deletions
diff --git a/src/gnunet_chat_contact.c b/src/gnunet_chat_contact.c
index e539245..6ef6506 100644
--- a/src/gnunet_chat_contact.c
+++ b/src/gnunet_chat_contact.c
@@ -28,6 +28,8 @@ struct GNUNET_CHAT_Contact*
28contact_create_from_member (struct GNUNET_CHAT_Handle *handle, 28contact_create_from_member (struct GNUNET_CHAT_Handle *handle,
29 const struct GNUNET_MESSENGER_Contact *member) 29 const struct GNUNET_MESSENGER_Contact *member)
30{ 30{
31 GNUNET_assert((handle) && (member));
32
31 struct GNUNET_CHAT_Contact* contact = GNUNET_new(struct GNUNET_CHAT_Contact); 33 struct GNUNET_CHAT_Contact* contact = GNUNET_new(struct GNUNET_CHAT_Contact);
32 34
33 contact->handle = handle; 35 contact->handle = handle;
@@ -43,5 +45,7 @@ contact_create_from_member (struct GNUNET_CHAT_Handle *handle,
43void 45void
44contact_destroy (struct GNUNET_CHAT_Contact* contact) 46contact_destroy (struct GNUNET_CHAT_Contact* contact)
45{ 47{
48 GNUNET_assert(contact);
49
46 GNUNET_free(contact); 50 GNUNET_free(contact);
47} 51}
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c
index 06f9c88..458063f 100644
--- a/src/gnunet_chat_context.c
+++ b/src/gnunet_chat_context.c
@@ -32,6 +32,8 @@ struct GNUNET_CHAT_Context*
32context_create_from_room (struct GNUNET_CHAT_Handle *handle, 32context_create_from_room (struct GNUNET_CHAT_Handle *handle,
33 struct GNUNET_MESSENGER_Room *room) 33 struct GNUNET_MESSENGER_Room *room)
34{ 34{
35 GNUNET_assert((handle) && (room));
36
35 struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); 37 struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context);
36 38
37 context->handle = handle; 39 context->handle = handle;
@@ -54,6 +56,12 @@ context_create_from_room (struct GNUNET_CHAT_Handle *handle,
54void 56void
55context_destroy (struct GNUNET_CHAT_Context* context) 57context_destroy (struct GNUNET_CHAT_Context* context)
56{ 58{
59 GNUNET_assert((context) &&
60 (context->timestamps) &&
61 (context->messages) &&
62 (context->invites) &&
63 (context->files));
64
57 GNUNET_CONTAINER_multishortmap_iterate( 65 GNUNET_CONTAINER_multishortmap_iterate(
58 context->timestamps, it_destroy_context_timestamps, NULL 66 context->timestamps, it_destroy_context_timestamps, NULL
59 ); 67 );
@@ -80,6 +88,10 @@ context_destroy (struct GNUNET_CHAT_Context* context)
80void 88void
81context_load_config (struct GNUNET_CHAT_Context *context) 89context_load_config (struct GNUNET_CHAT_Context *context)
82{ 90{
91 GNUNET_assert((context) &&
92 (context->handle) &&
93 (context->room));
94
83 const char *directory = context->handle->directory; 95 const char *directory = context->handle->directory;
84 96
85 if (!directory) 97 if (!directory)
@@ -119,6 +131,10 @@ free_filename:
119void 131void
120context_save_config (const struct GNUNET_CHAT_Context *context) 132context_save_config (const struct GNUNET_CHAT_Context *context)
121{ 133{
134 GNUNET_assert((context) &&
135 (context->handle) &&
136 (context->room));
137
122 const char *directory = context->handle->directory; 138 const char *directory = context->handle->directory;
123 139
124 if (!directory) 140 if (!directory)
diff --git a/src/gnunet_chat_context_intern.c b/src/gnunet_chat_context_intern.c
index 1ae146e..ed1cd27 100644
--- a/src/gnunet_chat_context_intern.c
+++ b/src/gnunet_chat_context_intern.c
@@ -32,6 +32,8 @@ it_destroy_context_timestamps (GNUNET_UNUSED void *cls,
32 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key, 32 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key,
33 void *value) 33 void *value)
34{ 34{
35 GNUNET_assert(value);
36
35 struct GNUNET_TIME_Absolute *time = value; 37 struct GNUNET_TIME_Absolute *time = value;
36 GNUNET_free(time); 38 GNUNET_free(time);
37 return GNUNET_YES; 39 return GNUNET_YES;
@@ -42,6 +44,8 @@ it_destroy_context_messages (GNUNET_UNUSED void *cls,
42 GNUNET_UNUSED const struct GNUNET_HashCode *key, 44 GNUNET_UNUSED const struct GNUNET_HashCode *key,
43 void *value) 45 void *value)
44{ 46{
47 GNUNET_assert(value);
48
45 struct GNUNET_CHAT_Message *message = value; 49 struct GNUNET_CHAT_Message *message = value;
46 message_destroy(message); 50 message_destroy(message);
47 return GNUNET_YES; 51 return GNUNET_YES;
@@ -52,6 +56,8 @@ it_destroy_context_invites (GNUNET_UNUSED void *cls,
52 GNUNET_UNUSED const struct GNUNET_HashCode *key, 56 GNUNET_UNUSED const struct GNUNET_HashCode *key,
53 void *value) 57 void *value)
54{ 58{
59 GNUNET_assert(value);
60
55 struct GNUNET_CHAT_Invitation *invitation = value; 61 struct GNUNET_CHAT_Invitation *invitation = value;
56 invitation_destroy(invitation); 62 invitation_destroy(invitation);
57 return GNUNET_YES; 63 return GNUNET_YES;
diff --git a/src/gnunet_chat_file.c b/src/gnunet_chat_file.c
index 063448e..13f5c2f 100644
--- a/src/gnunet_chat_file.c
+++ b/src/gnunet_chat_file.c
@@ -30,6 +30,10 @@ struct GNUNET_CHAT_File*
30file_create_from_message (struct GNUNET_CHAT_Handle *handle, 30file_create_from_message (struct GNUNET_CHAT_Handle *handle,
31 const struct GNUNET_MESSENGER_MessageFile* message) 31 const struct GNUNET_MESSENGER_MessageFile* message)
32{ 32{
33 GNUNET_assert((handle) &&
34 (message) &&
35 (message->name));
36
33 struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File); 37 struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File);
34 38
35 file->handle = handle; 39 file->handle = handle;
@@ -65,6 +69,11 @@ file_create_from_disk (struct GNUNET_CHAT_Handle *handle,
65 const char *name, const struct GNUNET_HashCode *hash, 69 const char *name, const struct GNUNET_HashCode *hash,
66 const struct GNUNET_CRYPTO_SymmetricSessionKey *key) 70 const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
67{ 71{
72 GNUNET_assert((handle) &&
73 (name) &&
74 (hash) &&
75 (key));
76
68 struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File); 77 struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File);
69 78
70 file->handle = handle; 79 file->handle = handle;
@@ -98,6 +107,8 @@ file_create_from_disk (struct GNUNET_CHAT_Handle *handle,
98void 107void
99file_destroy (struct GNUNET_CHAT_File* file) 108file_destroy (struct GNUNET_CHAT_File* file)
100{ 109{
110 GNUNET_assert(file);
111
101 struct GNUNET_CHAT_FileUpload *upload; 112 struct GNUNET_CHAT_FileUpload *upload;
102 while (file->upload_head) 113 while (file->upload_head)
103 { 114 {
@@ -156,6 +167,8 @@ void
156file_bind_upload (struct GNUNET_CHAT_File* file, 167file_bind_upload (struct GNUNET_CHAT_File* file,
157 GNUNET_CHAT_FileUploadCallback cb, void *cls) 168 GNUNET_CHAT_FileUploadCallback cb, void *cls)
158{ 169{
170 GNUNET_assert(file);
171
159 struct GNUNET_CHAT_FileUpload *upload = GNUNET_new( 172 struct GNUNET_CHAT_FileUpload *upload = GNUNET_new(
160 struct GNUNET_CHAT_FileUpload 173 struct GNUNET_CHAT_FileUpload
161 ); 174 );
@@ -174,6 +187,8 @@ void
174file_bind_downlaod (struct GNUNET_CHAT_File* file, 187file_bind_downlaod (struct GNUNET_CHAT_File* file,
175 GNUNET_CHAT_FileDownloadCallback cb, void *cls) 188 GNUNET_CHAT_FileDownloadCallback cb, void *cls)
176{ 189{
190 GNUNET_assert(file);
191
177 struct GNUNET_CHAT_FileDownload *download = GNUNET_new( 192 struct GNUNET_CHAT_FileDownload *download = GNUNET_new(
178 struct GNUNET_CHAT_FileDownload 193 struct GNUNET_CHAT_FileDownload
179 ); 194 );
@@ -192,6 +207,8 @@ void
192file_bind_unindex (struct GNUNET_CHAT_File* file, 207file_bind_unindex (struct GNUNET_CHAT_File* file,
193 GNUNET_CHAT_FileUnindexCallback cb, void *cls) 208 GNUNET_CHAT_FileUnindexCallback cb, void *cls)
194{ 209{
210 GNUNET_assert(file);
211
195 struct GNUNET_CHAT_FileUnindex *unindex = GNUNET_new( 212 struct GNUNET_CHAT_FileUnindex *unindex = GNUNET_new(
196 struct GNUNET_CHAT_FileUnindex 213 struct GNUNET_CHAT_FileUnindex
197 ); 214 );
@@ -210,6 +227,8 @@ void
210file_update_upload (struct GNUNET_CHAT_File* file, uint64_t completed, 227file_update_upload (struct GNUNET_CHAT_File* file, uint64_t completed,
211 uint64_t size) 228 uint64_t size)
212{ 229{
230 GNUNET_assert(file);
231
213 struct GNUNET_CHAT_FileUpload *upload = file->upload_head; 232 struct GNUNET_CHAT_FileUpload *upload = file->upload_head;
214 233
215 while (upload) 234 while (upload)
@@ -241,6 +260,8 @@ void
241file_update_download (struct GNUNET_CHAT_File* file, uint64_t completed, 260file_update_download (struct GNUNET_CHAT_File* file, uint64_t completed,
242 uint64_t size) 261 uint64_t size)
243{ 262{
263 GNUNET_assert(file);
264
244 struct GNUNET_CHAT_FileDownload *download = file->download_head; 265 struct GNUNET_CHAT_FileDownload *download = file->download_head;
245 266
246 while (download) 267 while (download)
@@ -272,6 +293,8 @@ void
272file_update_unindex (struct GNUNET_CHAT_File* file, uint64_t completed, 293file_update_unindex (struct GNUNET_CHAT_File* file, uint64_t completed,
273 uint64_t size) 294 uint64_t size)
274{ 295{
296 GNUNET_assert(file);
297
275 struct GNUNET_CHAT_FileUnindex *unindex = file->unindex_head; 298 struct GNUNET_CHAT_FileUnindex *unindex = file->unindex_head;
276 299
277 while (unindex) 300 while (unindex)
diff --git a/src/gnunet_chat_group.c b/src/gnunet_chat_group.c
index a2aab29..58782fa 100644
--- a/src/gnunet_chat_group.c
+++ b/src/gnunet_chat_group.c
@@ -31,6 +31,8 @@ struct GNUNET_CHAT_Group*
31group_create_from_context (struct GNUNET_CHAT_Handle *handle, 31group_create_from_context (struct GNUNET_CHAT_Handle *handle,
32 struct GNUNET_CHAT_Context *context) 32 struct GNUNET_CHAT_Context *context)
33{ 33{
34 GNUNET_assert((handle) && (context));
35
34 struct GNUNET_CHAT_Group* group = GNUNET_new(struct GNUNET_CHAT_Group); 36 struct GNUNET_CHAT_Group* group = GNUNET_new(struct GNUNET_CHAT_Group);
35 37
36 group->handle = handle; 38 group->handle = handle;
@@ -49,6 +51,8 @@ group_create_from_context (struct GNUNET_CHAT_Handle *handle,
49void 51void
50group_destroy (struct GNUNET_CHAT_Group* group) 52group_destroy (struct GNUNET_CHAT_Group* group)
51{ 53{
54 GNUNET_assert(group);
55
52 if (group->search) 56 if (group->search)
53 GNUNET_REGEX_search_cancel(group->search); 57 GNUNET_REGEX_search_cancel(group->search);
54 58
@@ -64,6 +68,11 @@ group_destroy (struct GNUNET_CHAT_Group* group)
64void 68void
65group_publish (struct GNUNET_CHAT_Group* group) 69group_publish (struct GNUNET_CHAT_Group* group)
66{ 70{
71 GNUNET_assert((group) &&
72 (group->topic) &&
73 (group->handle) &&
74 (group->handle->cfg));
75
67 char* topic = NULL; 76 char* topic = NULL;
68 GNUNET_asprintf ( 77 GNUNET_asprintf (
69 &topic, 78 &topic,
@@ -88,6 +97,8 @@ group_publish (struct GNUNET_CHAT_Group* group)
88void 97void
89group_load_config (struct GNUNET_CHAT_Group *group) 98group_load_config (struct GNUNET_CHAT_Group *group)
90{ 99{
100 GNUNET_assert((group) && (group->handle));
101
91 const char *directory = group->handle->directory; 102 const char *directory = group->handle->directory;
92 103
93 if ((!directory) || (!(group->context))) 104 if ((!directory) || (!(group->context)))
@@ -127,6 +138,8 @@ free_filename:
127void 138void
128group_save_config (const struct GNUNET_CHAT_Group *group) 139group_save_config (const struct GNUNET_CHAT_Group *group)
129{ 140{
141 GNUNET_assert((group) && (group->handle));
142
130 const char *directory = group->handle->directory; 143 const char *directory = group->handle->directory;
131 144
132 if ((!directory) || (!(group->context))) 145 if ((!directory) || (!(group->context)))
diff --git a/src/gnunet_chat_group_intern.c b/src/gnunet_chat_group_intern.c
index b70b901..76a35ca 100644
--- a/src/gnunet_chat_group_intern.c
+++ b/src/gnunet_chat_group_intern.c
@@ -37,6 +37,13 @@ search_group_by_topic(void *cls,
37{ 37{
38 struct GNUNET_CHAT_Group *group = cls; 38 struct GNUNET_CHAT_Group *group = cls;
39 39
40 GNUNET_assert((group) &&
41 (group->handle) &&
42 (group->handle->cfg) &&
43 (group->handle->messenger) &&
44 (group->context) &&
45 (group->context->room));
46
40 struct GNUNET_PeerIdentity peer; 47 struct GNUNET_PeerIdentity peer;
41 GNUNET_CRYPTO_get_peer_identity(group->handle->cfg, &peer); 48 GNUNET_CRYPTO_get_peer_identity(group->handle->cfg, &peer);
42 49
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
index 76454a5..4c1aa82 100644
--- a/src/gnunet_chat_handle.c
+++ b/src/gnunet_chat_handle.c
@@ -33,6 +33,8 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
33 GNUNET_CHAT_ContextMessageCallback msg_cb, 33 GNUNET_CHAT_ContextMessageCallback msg_cb,
34 void *msg_cls) 34 void *msg_cls)
35{ 35{
36 GNUNET_assert(cfg);
37
36 struct GNUNET_CHAT_Handle* handle = GNUNET_new(struct GNUNET_CHAT_Handle); 38 struct GNUNET_CHAT_Handle* handle = GNUNET_new(struct GNUNET_CHAT_Handle);
37 39
38 handle->cfg = cfg; 40 handle->cfg = cfg;
@@ -90,6 +92,12 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
90void 92void
91handle_destroy (struct GNUNET_CHAT_Handle* handle) 93handle_destroy (struct GNUNET_CHAT_Handle* handle)
92{ 94{
95 GNUNET_assert((handle) &&
96 (handle->groups) &&
97 (handle->contacts) &&
98 (handle->contexts) &&
99 (handle->files));
100
93 if (handle->messenger) 101 if (handle->messenger)
94 GNUNET_MESSENGER_disconnect(handle->messenger); 102 GNUNET_MESSENGER_disconnect(handle->messenger);
95 103
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index beb65d3..a563c60 100644
--- a/src/gnunet_chat_handle_intern.c
+++ b/src/gnunet_chat_handle_intern.c
@@ -38,6 +38,8 @@ on_handle_arm_connection(void *cls, int connected)
38{ 38{
39 struct GNUNET_CHAT_Handle *chat = cls; 39 struct GNUNET_CHAT_Handle *chat = cls;
40 40
41 GNUNET_assert((chat) && (chat->arm));
42
41 if (GNUNET_YES == connected) { 43 if (GNUNET_YES == connected) {
42 GNUNET_ARM_request_service_start( 44 GNUNET_ARM_request_service_start(
43 chat->arm, "messenger", 45 chat->arm, "messenger",
@@ -64,6 +66,8 @@ notify_handle_fs_progress(void* cls, const struct GNUNET_FS_ProgressInfo* info)
64{ 66{
65 struct GNUNET_CHAT_Handle *chat = cls; 67 struct GNUNET_CHAT_Handle *chat = cls;
66 68
69 GNUNET_assert(info);
70
67 if (!chat) 71 if (!chat)
68 return NULL; 72 return NULL;
69 73
@@ -194,6 +198,8 @@ check_handle_room_members (void* cls,
194{ 198{
195 struct GNUNET_CHAT_CheckHandleRoomMembers *check = cls; 199 struct GNUNET_CHAT_CheckHandleRoomMembers *check = cls;
196 200
201 GNUNET_assert((check) && (member));
202
197 const struct GNUNET_IDENTITY_PublicKey *member_key = ( 203 const struct GNUNET_IDENTITY_PublicKey *member_key = (
198 GNUNET_MESSENGER_contact_get_key(member) 204 GNUNET_MESSENGER_contact_get_key(member)
199 ); 205 );
@@ -215,6 +221,10 @@ int
215request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle, 221request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
216 struct GNUNET_MESSENGER_Room *room) 222 struct GNUNET_MESSENGER_Room *room)
217{ 223{
224 GNUNET_assert((handle) &&
225 (handle->contexts) &&
226 (room));
227
218 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room); 228 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room);
219 229
220 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get( 230 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get(
@@ -296,11 +306,14 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
296} 306}
297 307
298int 308int
299find_handle_rooms (void *cls, struct GNUNET_MESSENGER_Room *room, 309find_handle_rooms (void *cls,
310 struct GNUNET_MESSENGER_Room *room,
300 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member) 311 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member)
301{ 312{
302 struct GNUNET_CHAT_Handle *handle = cls; 313 struct GNUNET_CHAT_Handle *handle = cls;
303 314
315 GNUNET_assert((handle) && (room));
316
304 if (GNUNET_OK != request_handle_context_by_room(handle, room)) 317 if (GNUNET_OK != request_handle_context_by_room(handle, room))
305 return GNUNET_NO; 318 return GNUNET_NO;
306 319
@@ -314,6 +327,10 @@ scan_handle_room_members (void* cls,
314{ 327{
315 struct GNUNET_CHAT_Handle *handle = cls; 328 struct GNUNET_CHAT_Handle *handle = cls;
316 329
330 GNUNET_assert((handle) &&
331 (handle->contacts) &&
332 (member));
333
317 struct GNUNET_ShortHashCode shorthash; 334 struct GNUNET_ShortHashCode shorthash;
318 util_shorthash_from_member(member, &shorthash); 335 util_shorthash_from_member(member, &shorthash);
319 336
@@ -335,11 +352,16 @@ scan_handle_room_members (void* cls,
335} 352}
336 353
337int 354int
338scan_handle_rooms (void *cls, struct GNUNET_MESSENGER_Room *room, 355scan_handle_rooms (void *cls,
356 struct GNUNET_MESSENGER_Room *room,
339 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member) 357 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member)
340{ 358{
341 struct GNUNET_CHAT_Handle *handle = cls; 359 struct GNUNET_CHAT_Handle *handle = cls;
342 360
361 GNUNET_assert((handle) &&
362 (handle->groups) &&
363 (room));
364
343 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room); 365 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room);
344 366
345 struct GNUNET_CHAT_Group *group = GNUNET_CONTAINER_multihashmap_get( 367 struct GNUNET_CHAT_Group *group = GNUNET_CONTAINER_multihashmap_get(
@@ -359,11 +381,18 @@ on_handle_identity(void *cls,
359{ 381{
360 struct GNUNET_CHAT_Handle *handle = cls; 382 struct GNUNET_CHAT_Handle *handle = cls;
361 383
384 GNUNET_assert((handle) &&
385 (handle->contexts) &&
386 (handle->groups) &&
387 (handle->contacts));
388
362 if ((0 < GNUNET_CONTAINER_multihashmap_size(handle->contexts)) || 389 if ((0 < GNUNET_CONTAINER_multihashmap_size(handle->contexts)) ||
363 (0 < GNUNET_CONTAINER_multihashmap_size(handle->groups)) || 390 (0 < GNUNET_CONTAINER_multihashmap_size(handle->groups)) ||
364 (0 < GNUNET_CONTAINER_multishortmap_size(handle->contacts))) 391 (0 < GNUNET_CONTAINER_multishortmap_size(handle->contacts)))
365 return; 392 return;
366 393
394 GNUNET_assert(handle->messenger);
395
367 GNUNET_MESSENGER_find_rooms( 396 GNUNET_MESSENGER_find_rooms(
368 handle->messenger, NULL, find_handle_rooms, handle 397 handle->messenger, NULL, find_handle_rooms, handle
369 ); 398 );
@@ -393,6 +422,11 @@ on_handle_message (void *cls,
393{ 422{
394 struct GNUNET_CHAT_Handle *handle = cls; 423 struct GNUNET_CHAT_Handle *handle = cls;
395 424
425 GNUNET_assert((handle) &&
426 (room) &&
427 (msg) &&
428 (hash));
429
396 if (GNUNET_OK != request_handle_context_by_room(handle, room)) 430 if (GNUNET_OK != request_handle_context_by_room(handle, room))
397 return; 431 return;
398 432
@@ -502,6 +536,8 @@ it_destroy_handle_groups (GNUNET_UNUSED void *cls,
502 GNUNET_UNUSED const struct GNUNET_HashCode *key, 536 GNUNET_UNUSED const struct GNUNET_HashCode *key,
503 void *value) 537 void *value)
504{ 538{
539 GNUNET_assert(value);
540
505 struct GNUNET_CHAT_Group *group = value; 541 struct GNUNET_CHAT_Group *group = value;
506 group_save_config(group); 542 group_save_config(group);
507 group_destroy(group); 543 group_destroy(group);
@@ -513,6 +549,8 @@ it_destroy_handle_contacts (GNUNET_UNUSED void *cls,
513 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key, 549 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key,
514 void *value) 550 void *value)
515{ 551{
552 GNUNET_assert(value);
553
516 struct GNUNET_CHAT_Contact *contact = value; 554 struct GNUNET_CHAT_Contact *contact = value;
517 contact_destroy(contact); 555 contact_destroy(contact);
518 return GNUNET_YES; 556 return GNUNET_YES;
@@ -523,6 +561,8 @@ it_destroy_handle_contexts (GNUNET_UNUSED void *cls,
523 GNUNET_UNUSED const struct GNUNET_HashCode *key, 561 GNUNET_UNUSED const struct GNUNET_HashCode *key,
524 void *value) 562 void *value)
525{ 563{
564 GNUNET_assert(value);
565
526 struct GNUNET_CHAT_Context *context = value; 566 struct GNUNET_CHAT_Context *context = value;
527 context_save_config(context); 567 context_save_config(context);
528 context_destroy(context); 568 context_destroy(context);
@@ -534,6 +574,8 @@ it_destroy_handle_files (GNUNET_UNUSED void *cls,
534 GNUNET_UNUSED const struct GNUNET_HashCode *key, 574 GNUNET_UNUSED const struct GNUNET_HashCode *key,
535 void *value) 575 void *value)
536{ 576{
577 GNUNET_assert(value);
578
537 struct GNUNET_CHAT_File *file = value; 579 struct GNUNET_CHAT_File *file = value;
538 file_destroy(file); 580 file_destroy(file);
539 return GNUNET_YES; 581 return GNUNET_YES;
diff --git a/src/gnunet_chat_invitation.c b/src/gnunet_chat_invitation.c
index 9562daa..40c5769 100644
--- a/src/gnunet_chat_invitation.c
+++ b/src/gnunet_chat_invitation.c
@@ -28,6 +28,8 @@ struct GNUNET_CHAT_Invitation*
28invitation_create_from_message (struct GNUNET_CHAT_Context *context, 28invitation_create_from_message (struct GNUNET_CHAT_Context *context,
29 const struct GNUNET_MESSENGER_MessageInvite *message) 29 const struct GNUNET_MESSENGER_MessageInvite *message)
30{ 30{
31 GNUNET_assert((context) && (message));
32
31 struct GNUNET_CHAT_Invitation *invitation = GNUNET_new(struct GNUNET_CHAT_Invitation); 33 struct GNUNET_CHAT_Invitation *invitation = GNUNET_new(struct GNUNET_CHAT_Invitation);
32 34
33 invitation->context = context; 35 invitation->context = context;
@@ -41,6 +43,8 @@ invitation_create_from_message (struct GNUNET_CHAT_Context *context,
41void 43void
42invitation_destroy (struct GNUNET_CHAT_Invitation *invitation) 44invitation_destroy (struct GNUNET_CHAT_Invitation *invitation)
43{ 45{
46 GNUNET_assert(invitation);
47
44 GNUNET_PEER_decrement_rcs(&(invitation->door), 1); 48 GNUNET_PEER_decrement_rcs(&(invitation->door), 1);
45 49
46 GNUNET_free(invitation); 50 GNUNET_free(invitation);
diff --git a/src/gnunet_chat_lib_intern.c b/src/gnunet_chat_lib_intern.c
index 1518f60..6d72cbf 100644
--- a/src/gnunet_chat_lib_intern.c
+++ b/src/gnunet_chat_lib_intern.c
@@ -36,6 +36,8 @@ it_handle_iterate_contacts (void *cls,
36 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key, 36 GNUNET_UNUSED const struct GNUNET_ShortHashCode *key,
37 void *value) 37 void *value)
38{ 38{
39 GNUNET_assert((cls) && (value));
40
39 struct GNUNET_CHAT_HandleIterateContacts *it = cls; 41 struct GNUNET_CHAT_HandleIterateContacts *it = cls;
40 42
41 if (!(it->cb)) 43 if (!(it->cb))
@@ -58,6 +60,8 @@ it_handle_iterate_groups (void *cls,
58 GNUNET_UNUSED const struct GNUNET_HashCode *key, 60 GNUNET_UNUSED const struct GNUNET_HashCode *key,
59 void *value) 61 void *value)
60{ 62{
63 GNUNET_assert((cls) && (value));
64
61 struct GNUNET_CHAT_HandleIterateGroups *it = cls; 65 struct GNUNET_CHAT_HandleIterateGroups *it = cls;
62 66
63 if (!(it->cb)) 67 if (!(it->cb))
@@ -74,9 +78,12 @@ struct GNUNET_CHAT_ContactFindRoom
74}; 78};
75 79
76int 80int
77it_contact_find_room (void *cls, struct GNUNET_MESSENGER_Room *room, 81it_contact_find_room (void *cls,
82 struct GNUNET_MESSENGER_Room *room,
78 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member) 83 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member)
79{ 84{
85 GNUNET_assert((cls) && (room));
86
80 struct GNUNET_CHAT_ContactFindRoom *find = cls; 87 struct GNUNET_CHAT_ContactFindRoom *find = cls;
81 find->room = room; 88 find->room = room;
82 return GNUNET_NO; 89 return GNUNET_NO;
@@ -94,6 +101,8 @@ it_group_iterate_contacts (void* cls,
94 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room, 101 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room,
95 const struct GNUNET_MESSENGER_Contact *member) 102 const struct GNUNET_MESSENGER_Contact *member)
96{ 103{
104 GNUNET_assert((cls) && (member));
105
97 struct GNUNET_CHAT_GroupIterateContacts *it = cls; 106 struct GNUNET_CHAT_GroupIterateContacts *it = cls;
98 107
99 if (!(it->cb)) 108 if (!(it->cb))
@@ -121,6 +130,8 @@ it_context_iterate_messages (void *cls,
121 GNUNET_UNUSED const struct GNUNET_HashCode *key, 130 GNUNET_UNUSED const struct GNUNET_HashCode *key,
122 void *value) 131 void *value)
123{ 132{
133 GNUNET_assert((cls) && (value));
134
124 struct GNUNET_CHAT_ContextIterateMessages *it = cls; 135 struct GNUNET_CHAT_ContextIterateMessages *it = cls;
125 136
126 if (!(it->cb)) 137 if (!(it->cb))
@@ -143,6 +154,8 @@ it_context_iterate_files (void *cls,
143 GNUNET_UNUSED const struct GNUNET_HashCode *key, 154 GNUNET_UNUSED const struct GNUNET_HashCode *key,
144 void *value) 155 void *value)
145{ 156{
157 GNUNET_assert((cls) && (value));
158
146 struct GNUNET_CHAT_ContextIterateFiles *it = cls; 159 struct GNUNET_CHAT_ContextIterateFiles *it = cls;
147 160
148 if (!(it->cb)) 161 if (!(it->cb))
@@ -165,6 +178,8 @@ it_message_iterate_read_receipts (void *cls,
165 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room, 178 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room,
166 const struct GNUNET_MESSENGER_Contact *member) 179 const struct GNUNET_MESSENGER_Contact *member)
167{ 180{
181 GNUNET_assert((cls) && (member));
182
168 struct GNUNET_CHAT_MessageIterateReadReceipts *it = cls; 183 struct GNUNET_CHAT_MessageIterateReadReceipts *it = cls;
169 struct GNUNET_CHAT_Handle *handle = it->message->context->handle; 184 struct GNUNET_CHAT_Handle *handle = it->message->context->handle;
170 185
diff --git a/src/gnunet_chat_message.c b/src/gnunet_chat_message.c
index a396cf8..e044415 100644
--- a/src/gnunet_chat_message.c
+++ b/src/gnunet_chat_message.c
@@ -30,6 +30,10 @@ message_create_from_msg (struct GNUNET_CHAT_Context *context,
30 enum GNUNET_MESSENGER_MessageFlags flags, 30 enum GNUNET_MESSENGER_MessageFlags flags,
31 const struct GNUNET_MESSENGER_Message *msg) 31 const struct GNUNET_MESSENGER_Message *msg)
32{ 32{
33 GNUNET_assert((context) &&
34 (hash) &&
35 (msg));
36
33 struct GNUNET_CHAT_Message *message = GNUNET_new(struct GNUNET_CHAT_Message); 37 struct GNUNET_CHAT_Message *message = GNUNET_new(struct GNUNET_CHAT_Message);
34 38
35 message->context = context; 39 message->context = context;
@@ -64,5 +68,7 @@ message_create_internally (struct GNUNET_CHAT_Context *context,
64void 68void
65message_destroy (struct GNUNET_CHAT_Message* message) 69message_destroy (struct GNUNET_CHAT_Message* message)
66{ 70{
71 GNUNET_assert(message);
72
67 GNUNET_free(message); 73 GNUNET_free(message);
68} 74}
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
index 836286f..c162aea 100644
--- a/src/gnunet_chat_util.c
+++ b/src/gnunet_chat_util.c
@@ -28,6 +28,8 @@ void
28util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member, 28util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member,
29 struct GNUNET_ShortHashCode *shorthash) 29 struct GNUNET_ShortHashCode *shorthash)
30{ 30{
31 GNUNET_assert((member) && (shorthash));
32
31 memset(shorthash, 0, sizeof(*shorthash)); 33 memset(shorthash, 0, sizeof(*shorthash));
32 GNUNET_memcpy(shorthash, &member, sizeof(member)); 34 GNUNET_memcpy(shorthash, &member, sizeof(member));
33} 35}
@@ -35,6 +37,8 @@ util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member,
35void 37void
36util_set_name_field (const char *name, char **field) 38util_set_name_field (const char *name, char **field)
37{ 39{
40 GNUNET_assert(field);
41
38 if (*field) 42 if (*field)
39 GNUNET_free(*field); 43 GNUNET_free(*field);
40 44
@@ -47,6 +51,8 @@ util_set_name_field (const char *name, char **field)
47int 51int
48util_hash_file (const char *filename, struct GNUNET_HashCode *hash) 52util_hash_file (const char *filename, struct GNUNET_HashCode *hash)
49{ 53{
54 GNUNET_assert((filename) && (hash));
55
50 uint64_t size; 56 uint64_t size;
51 57
52 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES)) 58 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES))
@@ -82,6 +88,8 @@ int
82util_encrypt_file (const char *filename, 88util_encrypt_file (const char *filename,
83 const struct GNUNET_CRYPTO_SymmetricSessionKey *key) 89 const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
84{ 90{
91 GNUNET_assert((filename) && (key));
92
85 uint64_t size; 93 uint64_t size;
86 94
87 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES)) 95 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES))
@@ -130,6 +138,8 @@ int
130util_decrypt_file (const char *filename, 138util_decrypt_file (const char *filename,
131 const struct GNUNET_CRYPTO_SymmetricSessionKey *key) 139 const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
132{ 140{
141 GNUNET_assert((filename) && (key));
142
133 uint64_t size; 143 uint64_t size;
134 144
135 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES)) 145 if (GNUNET_OK != GNUNET_DISK_file_size(filename, &size, GNUNET_NO, GNUNET_YES))
@@ -175,10 +185,16 @@ util_decrypt_file (const char *filename,
175} 185}
176 186
177int 187int
178util_get_filename (const char *directory, const char *subdir, 188util_get_filename (const char *directory,
189 const char *subdir,
179 const struct GNUNET_HashCode *hash, 190 const struct GNUNET_HashCode *hash,
180 char **filename) 191 char **filename)
181{ 192{
193 GNUNET_assert((filename) &&
194 (directory) &&
195 (subdir) &&
196 (hash));
197
182 return GNUNET_asprintf ( 198 return GNUNET_asprintf (
183 filename, 199 filename,
184 "%s%s%c%s", 200 "%s%s%c%s",