Browse code

Fix missing return value checks in multi_process_float()

Fix the missing return value checks on hash_remove() and hash_add() by
replacing the calls with an single hash_add() call with the replace
parameters set to true so that is can't fail. Then just ASSERT() that
this is indeed the case.

This also replaces the other add/remove combinations with a single
add-replace, because that should be slightly faster (and this is in the
'hot path').

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1478635663-5837-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12968.html
Signed-off-by: David Sommerseth <davids@openvpn.net>

Steffan Karger authored on 2016/11/09 05:07:43
Showing 1 changed files
... ...
@@ -2317,9 +2317,6 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
2317 2317
 	mroute_addr_print (&mi->real, &gc),
2318 2318
 	print_link_socket_actual (&m->top.c2.from, &gc));
2319 2319
 
2320
-    ASSERT (hash_remove(m->hash, &mi->real));
2321
-    ASSERT (hash_remove(m->iter, &mi->real));
2322
-
2323 2320
     /* change external network address of the remote peer */
2324 2321
     mi->real = real;
2325 2322
     generate_prefix (mi);
... ...
@@ -2333,12 +2330,11 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
2333 2333
 
2334 2334
     tls_update_remote_addr (mi->context.c2.tls_multi, &mi->context.c2.from);
2335 2335
 
2336
-    ASSERT (hash_add (m->hash, &mi->real, mi, false));
2337
-    ASSERT (hash_add (m->iter, &mi->real, mi, false));
2336
+    ASSERT (hash_add (m->hash, &mi->real, mi, true));
2337
+    ASSERT (hash_add (m->iter, &mi->real, mi, true));
2338 2338
 
2339 2339
 #ifdef MANAGEMENT_DEF_AUTH
2340
-    hash_remove (m->cid_hash, &mi->context.c2.mda_context.cid);
2341
-    hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, false);
2340
+    ASSERT (hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, true));
2342 2341
 #endif
2343 2342
 
2344 2343
 done: