Commit adc19d556533254f7f3fe8101c25f9de1ca46331

Stefan Sperling 2019-07-28T12:48:56

remove pointless output parameter from got_pathlist_append()

diff --git a/got/got.c b/got/got.c
index 41f97f7..dc2cda4 100644
--- a/got/got.c
+++ b/got/got.c
@@ -955,7 +955,7 @@ cmd_checkout(int argc, char *argv[])
 			goto done;
 	}
 
-	error = got_pathlist_append(NULL, &paths, "", NULL);
+	error = got_pathlist_append(&paths, "", NULL);
 	if (error)
 		goto done;
 	error = got_worktree_checkout_files(worktree, &paths, repo,
@@ -1074,14 +1074,14 @@ get_worktree_paths_from_argv(struct got_pathlist_head *paths, int argc,
 		path = strdup("");
 		if (path == NULL)
 			return got_error_from_errno("strdup");
-		return got_pathlist_append(NULL, paths, path, NULL);
+		return got_pathlist_append(paths, path, NULL);
 	}
 
 	for (i = 0; i < argc; i++) {
 		err = got_worktree_resolve_path(&path, worktree, argv[i]);
 		if (err)
 			break;
-		err = got_pathlist_append(NULL, paths, path, NULL);
+		err = got_pathlist_append(paths, path, NULL);
 		if (err) {
 			free(path);
 			break;
@@ -1862,7 +1862,7 @@ cmd_diff(int argc, char *argv[])
 		arg.id_str = id_str;
 		arg.header_shown = 0;
 
-		error = got_pathlist_append(NULL, &paths, path, NULL);
+		error = got_pathlist_append(&paths, path, NULL);
 		if (error)
 			goto done;
 
diff --git a/include/got_path.h b/include/got_path.h
index 56a5865..34114a2 100644
--- a/include/got_path.h
+++ b/include/got_path.h
@@ -83,11 +83,9 @@ const struct got_error *got_pathlist_insert(struct got_pathlist_entry **,
  * The caller should already have initialized the list head. This list stores
  * the pointer to the path as-is, i.e. the path is not copied internally and
  * must remain available until the list is freed with got_pathlist_free().
- * If the first argument is not NULL, set it to a pointer to the newly inserted
- * element, or to a NULL pointer in case the path was already on the list.
  */
-const struct got_error *got_pathlist_append(struct got_pathlist_entry **,
-    struct got_pathlist_head *, const char *, void *);
+const struct got_error *got_pathlist_append(struct got_pathlist_head *,
+    const char *, void *);
 
 /* Free resources allocated for a path list. */
 void got_pathlist_free(struct got_pathlist_head *);
diff --git a/lib/path.c b/lib/path.c
index 66561a0..a4c1a16 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -254,8 +254,8 @@ got_pathlist_insert(struct got_pathlist_entry **inserted,
 }
 
 const struct got_error *
-got_pathlist_append(struct got_pathlist_entry **pe,
-    struct got_pathlist_head *pathlist, const char *path, void *data)
+got_pathlist_append(struct got_pathlist_head *pathlist,
+    const char *path, void *data)
 {
 	struct got_pathlist_entry *new;
 
@@ -265,8 +265,6 @@ got_pathlist_append(struct got_pathlist_entry **pe,
 	new->path = path;
 	new->data = data;
 	TAILQ_INSERT_TAIL(pathlist, new, entry);
-	if (pe)
-		*pe = new;
 	return NULL;
 }
 
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index dc88ba8..3df09c5 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -378,7 +378,7 @@ worktree_checkout(const char *repo_path)
 	if (err != NULL)
 		goto done;
 
-	err = got_pathlist_append(NULL, &paths, "", NULL);
+	err = got_pathlist_append(&paths, "", NULL);
 	if (err)
 		goto done;
 	err = got_worktree_checkout_files(worktree, &paths, repo, progress_cb,