Commit 96cbb59708cdbe5ff619b9d9cccae495277071e5

Stefan Sperling 2019-10-09T08:24:38

remove worklist code; it was only used to unlink files which we already unlink

diff --git a/got/Makefile b/got/Makefile
index 4d88777..4310fc7 100644
--- a/got/Makefile
+++ b/got/Makefile
@@ -7,7 +7,7 @@ SRCS=		got.c blame.c commit_graph.c delta.c diff.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
 		privsep.c reference.c repository.c sha1.c worktree.c \
-		inflate.c buf.c worklist.c rcsutil.c diff3.c lockfile.c \
+		inflate.c buf.c rcsutil.c diff3.c lockfile.c \
 		deflate.c object_create.c
 MAN =		${PROG}.1 got-worktree.5 git-repository.5
 
diff --git a/lib/buf.c b/lib/buf.c
index a2d26a3..91c1809 100644
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -36,7 +36,6 @@
 #include <unistd.h>
 
 #include "buf.h"
-#include "worklist.h"
 
 #include "got_error.h"
 
@@ -323,7 +322,7 @@ buf_write(BUF *b, const char *path, mode_t mode)
  * NB. This function will modify <template>, as per mkstemp
  */
 const struct got_error *
-buf_write_stmp(BUF *b, char *template, struct wklhead *temp_files)
+buf_write_stmp(BUF *b, char *template)
 {
 	const struct got_error *err = NULL;
 	int fd;
@@ -331,8 +330,6 @@ buf_write_stmp(BUF *b, char *template, struct wklhead *temp_files)
 	if ((fd = mkstemp(template)) == -1)
 		return got_error_from_errno("mkstemp");
 
-	worklist_add(template, temp_files);
-
 	if (buf_write_fd(b, fd) == -1) {
 		err = got_error_from_errno("buf_write_fd");
 		(void)unlink(template);
diff --git a/lib/buf.h b/lib/buf.h
index 6bc2401..dcb2af9 100644
--- a/lib/buf.h
+++ b/lib/buf.h
@@ -41,7 +41,6 @@
 #include <sys/types.h>
 
 typedef struct buf BUF;
-struct wklhead;
 
 const struct got_error *buf_alloc(BUF **, size_t);
 const struct got_error *buf_load(BUF **, const char *);
@@ -55,7 +54,7 @@ const struct got_error *buf_puts(size_t *, BUF *b, const char *str);
 size_t		 buf_len(BUF *);
 int		 buf_write_fd(BUF *, int);
 const struct got_error *buf_write(BUF *, const char *, mode_t);
-const struct got_error *buf_write_stmp(BUF *, char *, struct wklhead *);
+const struct got_error *buf_write_stmp(BUF *, char *);
 u_char		*buf_get(BUF *b);
 
 #endif	/* BUF_H */
diff --git a/lib/diff3.c b/lib/diff3.c
index c088b41..1948809 100644
--- a/lib/diff3.c
+++ b/lib/diff3.c
@@ -83,7 +83,6 @@
 #include "buf.h"
 #include "rcsutil.h"
 #include "got_lib_diff.h"
-#include "worklist.h"
 
 #ifndef nitems
 #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
@@ -270,14 +269,11 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
 	BUF *b1, *b2, *b3, *d1, *d2, *diffb;
 	u_char *data, *patch;
 	size_t dlen, plen;
-	struct wklhead temp_files;
 	struct diff3_state *d3s;
 	int i;
 
 	*overlapcnt = 0;
 
-	SLIST_INIT(&temp_files);
-
 	d3s = calloc(1, sizeof(*d3s));
 	if (d3s == NULL)
 		return got_error_from_errno("calloc");
@@ -313,13 +309,13 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
 		goto out;
 	}
 
-	err = buf_write_stmp(b1, path1, &temp_files);
+	err = buf_write_stmp(b1, path1);
 	if (err)
 		goto out;
-	err = buf_write_stmp(b2, path2, &temp_files);
+	err = buf_write_stmp(b2, path2);
 	if (err)
 		goto out;
-	err = buf_write_stmp(b3, path3, &temp_files);
+	err = buf_write_stmp(b3, path3);
 	if (err)
 		goto out;
 
@@ -344,7 +340,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
 		err = got_error_from_errno("asprintf");
 		goto out;
 	}
-	err = buf_write_stmp(d1, dp13, &temp_files);
+	err = buf_write_stmp(d1, dp13);
 	if (err)
 		goto out;
 
@@ -355,7 +351,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
 		err = got_error_from_errno("asprintf");
 		goto out;
 	}
-	err = buf_write_stmp(d2, dp23, &temp_files);
+	err = buf_write_stmp(d2, dp23);
 	if (err)
 		goto out;
 
@@ -402,8 +398,6 @@ out:
 	free(data);
 	free(patch);
 
-	worklist_clean(&temp_files, worklist_unlink);
-
 	for (i = 0; i < nitems(d3s->fp); i++) {
 		if (d3s->fp[i] && fclose(d3s->fp[i]) != 0 && err == NULL)
 			err = got_error_from_errno("fclose");
diff --git a/lib/worklist.c b/lib/worklist.c
deleted file mode 100644
index bbdcd9d..0000000
--- a/lib/worklist.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*	$OpenBSD: worklist.c,v 1.4 2015/06/13 20:15:21 nicm Exp $	*/
-/*
- * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/queue.h>
-
-#include <err.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "worklist.h"
-#include "got_error.h"
-
-/*
- * adds a path to a worklist.
- */
-const struct got_error *
-worklist_add(const char *path, struct wklhead *worklist)
-{
-	size_t len;
-	struct worklist *wkl;
-	sigset_t old, new;
-
-	wkl = calloc(1, sizeof(*wkl));
-	if (wkl == NULL)
-		return got_error_from_errno("calloc");
-
-	len = strlcpy(wkl->wkl_path, path, sizeof(wkl->wkl_path));
-	if (len >= sizeof(wkl->wkl_path)) {
-		free(wkl);
-		return got_error(GOT_ERR_NO_SPACE);
-	}
-
-	sigfillset(&new);
-	sigprocmask(SIG_BLOCK, &new, &old);
-	SLIST_INSERT_HEAD(worklist, wkl, wkl_list);
-	sigprocmask(SIG_SETMASK, &old, NULL);
-	return NULL;
-}
-
-/*
- * run over the given worklist, calling cb for each element.
- * this is just like worklist_clean(), except we block signals first.
- */
-void
-worklist_run(struct wklhead *list, void (*cb)(struct worklist *))
-{
-	sigset_t old, new;
-	struct worklist *wkl;
-
-	sigfillset(&new);
-	sigprocmask(SIG_BLOCK, &new, &old);
-
-	worklist_clean(list, cb);
-
-	while ((wkl = SLIST_FIRST(list)) != NULL) {
-		SLIST_REMOVE_HEAD(list, wkl_list);
-		free(wkl);
-	}
-
-	sigprocmask(SIG_SETMASK, &old, NULL);
-}
-
-/*
- * pass elements to the specified callback, which has to be signal safe.
- */
-void
-worklist_clean(struct wklhead *list, void (*cb)(struct worklist *))
-{
-	struct worklist *wkl;
-
-	SLIST_FOREACH(wkl, list, wkl_list)
-	    cb(wkl);
-}
-
-void
-worklist_unlink(struct worklist *wkl)
-{
-	(void)unlink(wkl->wkl_path);
-}
diff --git a/lib/worklist.h b/lib/worklist.h
deleted file mode 100644
index bb59617..0000000
--- a/lib/worklist.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*	$OpenBSD: worklist.h,v 1.4 2015/01/16 06:40:11 deraadt Exp $	*/
-/*
- * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WORKLIST_H
-#define WORKLIST_H
-
-#include <sys/types.h>
-#include <limits.h>
-
-struct worklist {
-	char				wkl_path[PATH_MAX];
-	volatile SLIST_ENTRY(worklist)	wkl_list;
-};
-
-SLIST_HEAD(wklhead, worklist);
-
-const struct got_error *worklist_add(const char *, struct wklhead *);
-void worklist_run(struct wklhead *, void (*cb)(struct worklist *));
-void worklist_clean(struct wklhead *, void (*cb)(struct worklist *));
-
-void worklist_unlink(struct worklist *);
-
-#endif
diff --git a/tog/Makefile b/tog/Makefile
index 85f9a89..531c090 100644
--- a/tog/Makefile
+++ b/tog/Makefile
@@ -7,7 +7,7 @@ SRCS=		tog.c blame.c commit_graph.c delta.c diff.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
 		privsep.c reference.c repository.c sha1.c worktree.c \
-		utf8.c inflate.c buf.c worklist.c rcsutil.c diff3.c \
+		utf8.c inflate.c buf.c rcsutil.c diff3.c \
 		lockfile.c deflate.c object_create.c
 MAN =		${PROG}.1