Commit 8f6d9a6a62b3640c758a23e26cd567e2e44406e1

Stefan Sperling 2019-01-08T21:48:28

mark got_pathset iteration functions as safe

diff --git a/lib/got_lib_pathset.h b/lib/got_lib_pathset.h
index 2eb5498..098dd95 100644
--- a/lib/got_lib_pathset.h
+++ b/lib/got_lib_pathset.h
@@ -25,10 +25,10 @@ void *got_pathset_get(struct got_pathset *, const char *);
 const struct got_error *got_pathset_remove(void **, struct got_pathset *,
     const char *);
 int got_pathset_contains(struct got_pathset *, const char *);
-const struct got_error *got_pathset_for_each(struct got_pathset *,
+const struct got_error *got_pathset_for_each_safe(struct got_pathset *,
     const struct got_error *(*cb)(const char *, void *, void *),
     void *);
-const struct got_error *got_pathset_for_each_reverse(struct got_pathset *,
+const struct got_error *got_pathset_for_each_reverse_safe(struct got_pathset *,
     const struct got_error *(*cb)(const char *, void *, void *),
     void *);
 int got_pathset_num_elements(struct got_pathset *);
diff --git a/lib/pathset.c b/lib/pathset.c
index 66676de..828ea4b 100644
--- a/lib/pathset.c
+++ b/lib/pathset.c
@@ -185,7 +185,7 @@ got_pathset_contains(struct got_pathset *set, const char *path)
 }
 
 const struct got_error *
-got_pathset_for_each(struct got_pathset *set,
+got_pathset_for_each_safe(struct got_pathset *set,
     const struct got_error *(*cb)(const char *, void *, void *), void *arg)
 {
 	const struct got_error *err;
@@ -200,7 +200,7 @@ got_pathset_for_each(struct got_pathset *set,
 }
 
 const struct got_error *
-got_pathset_for_each_reverse(struct got_pathset *set,
+got_pathset_for_each_reverse_safe(struct got_pathset *set,
     const struct got_error *(*cb)(const char *, void *, void *), void *arg)
 {
 	const struct got_error *err;
diff --git a/lib/worktree.c b/lib/worktree.c
index 7678188..56b3803 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -862,7 +862,8 @@ remove_missing_files(struct got_worktree *worktree, const char *path,
 	a2.cancel_arg = cancel_arg;
 	a2.progress_cb = progress_cb;
 	a2.progress_arg = progress_arg;
-	err = got_pathset_for_each(a.missing_entries, remove_missing_file, &a2);
+	err = got_pathset_for_each_safe(a.missing_entries, remove_missing_file,
+	    &a2);
 	got_pathset_free(a.missing_entries);
 	return err;
 }
diff --git a/regress/pathset/pathset_test.c b/regress/pathset/pathset_test.c
index 55c5c62..9cd8b5a 100644
--- a/regress/pathset/pathset_test.c
+++ b/regress/pathset/pathset_test.c
@@ -124,7 +124,7 @@ pathset_add_remove_iter(void)
 		goto done;
 	}
 
-	got_pathset_for_each(set, pathset_add_remove_iter_cb, NULL);
+	got_pathset_for_each_safe(set, pathset_add_remove_iter_cb, NULL);
 done:
 	got_pathset_free(set);
 	return (err == NULL);
@@ -213,9 +213,9 @@ pathset_iter_order(void)
 		goto done;
 
 	test_printf("normal order:\n");
-	got_pathset_for_each(set, pathset_iter_order_cb, NULL);
+	got_pathset_for_each_safe(set, pathset_iter_order_cb, NULL);
 	test_printf("reverse order:\n");
-	got_pathset_for_each_reverse(set, pathset_iter_reverse_order_cb,
+	got_pathset_for_each_reverse_safe(set, pathset_iter_reverse_order_cb,
 	    NULL);
 done:
 	got_pathset_free(set);