Skip to content

Commit

Permalink
parallel-hmap: rewrite iterator using multivar helpers
Browse files Browse the repository at this point in the history
Rewrite the parallel hmap iterator macros using multivariable iterator
helpers to avoid undefined behavior.

Suggested-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
amorenoz authored and putnopvut committed Apr 26, 2022
1 parent 985ef45 commit 3da85a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/ovn-parallel-hmap.h
Expand Up @@ -58,11 +58,11 @@ extern "C" {
* ThreadID + step * i as the JOBID parameter.
*/

#define HMAP_FOR_EACH_IN_PARALLEL(NODE, MEMBER, JOBID, HMAP) \
for (INIT_CONTAINER(NODE, hmap_first_in_bucket_num(HMAP, JOBID), MEMBER); \
(NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
|| ((NODE = NULL), false); \
ASSIGN_CONTAINER(NODE, hmap_next_in_bucket(&(NODE)->MEMBER), MEMBER))
#define HMAP_FOR_EACH_IN_PARALLEL(NODE, MEMBER, JOBID, HMAP) \
for (INIT_MULTIVAR(NODE, MEMBER, hmap_first_in_bucket_num(HMAP, JOBID), \
struct hmap_node); \
CONDITION_MULTIVAR(NODE, MEMBER, ITER_VAR(NODE) != NULL); \
UPDATE_MULTIVAR(NODE, hmap_next_in_bucket(ITER_VAR(NODE))))

/* We do not have a SAFE version of the macro, because the hash size is not
* atomic and hash removal operations would need to be wrapped with
Expand Down

0 comments on commit 3da85a6

Please sign in to comment.