Commit 2ff12563f8266a459fcfc4d3b635d320c0a761d7

Stefan Sperling 2018-09-15T12:39:48

fix 'make PROFILE=1' build

diff --git a/lib/object.c b/lib/object.c
index 7c7fdf3..e0a3cb4 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -56,24 +56,6 @@
 #define	MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
 #endif
 
-const struct got_error *
-got_object_id_str(char **outbuf, struct got_object_id *id)
-{
-	static const size_t len = SHA1_DIGEST_STRING_LENGTH;
-
-	*outbuf = malloc(len);
-	if (*outbuf == NULL)
-		return got_error_from_errno();
-
-	if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
-		free(*outbuf);
-		*outbuf = NULL;
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
-	}
-
-	return NULL;
-}
-
 int
 got_object_id_cmp(struct got_object_id *id1, struct got_object_id *id2)
 {
diff --git a/lib/object_parse.c b/lib/object_parse.c
index bab79fa..2ff896a 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -62,6 +62,24 @@
 #define GOT_COMMIT_TAG_AUTHOR		"author "
 #define GOT_COMMIT_TAG_COMMITTER	"committer "
 
+const struct got_error *
+got_object_id_str(char **outbuf, struct got_object_id *id)
+{
+	static const size_t len = SHA1_DIGEST_STRING_LENGTH;
+
+	*outbuf = malloc(len);
+	if (*outbuf == NULL)
+		return got_error_from_errno();
+
+	if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
+		free(*outbuf);
+		*outbuf = NULL;
+		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+	}
+
+	return NULL;
+}
+
 void
 got_object_close(struct got_object *obj)
 {
diff --git a/libexec/got-read-blob/got-read-blob.c b/libexec/got-read-blob/got-read-blob.c
index 24a3577..0713310 100644
--- a/libexec/got-read-blob/got-read-blob.c
+++ b/libexec/got-read-blob/got-read-blob.c
@@ -47,12 +47,14 @@ main(int argc, char *argv[])
 
 	imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
 
+#ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
 		err = got_error_from_errno();
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
+#endif
 
 	while (1) {
 		struct imsg imsg, imsg_outfd;
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 7936f1a..f6b5435 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -76,12 +76,14 @@ main(int argc, char *argv[])
 
 	imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
 
+#ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
 		err = got_error_from_errno();
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
+#endif
 
 	while (1) {
 		struct imsg imsg;
diff --git a/libexec/got-read-object/got-read-object.c b/libexec/got-read-object/got-read-object.c
index 8a78746..baca773 100644
--- a/libexec/got-read-object/got-read-object.c
+++ b/libexec/got-read-object/got-read-object.c
@@ -156,12 +156,14 @@ main(int argc, char *argv[])
 
 	imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
 
+#ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
 		err = got_error_from_errno();
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
+#endif
 
 	while (1) {
 		err = got_privsep_recv_imsg(&imsg, &ibuf, 0);
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 51e3ea5..2238e3a 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -411,12 +411,14 @@ main(int argc, char *argv[])
 		return 1;
 	}
 
+#ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
 		err = got_error_from_errno();
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
+#endif
 
 	err = receive_packidx(&packidx, &ibuf);
 	if (err) {
diff --git a/libexec/got-read-tree/got-read-tree.c b/libexec/got-read-tree/got-read-tree.c
index cb003bb..5abd564 100644
--- a/libexec/got-read-tree/got-read-tree.c
+++ b/libexec/got-read-tree/got-read-tree.c
@@ -75,12 +75,14 @@ main(int argc, char *argv[])
 
 	imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
 
+#ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
 		err = got_error_from_errno();
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
+#endif
 
 	while (1) {
 		struct imsg imsg;
diff --git a/regress/delta/delta_test.c b/regress/delta/delta_test.c
index f8b0bfa..09019b9 100644
--- a/regress/delta/delta_test.c
+++ b/regress/delta/delta_test.c
@@ -47,7 +47,7 @@ struct delta_test {
 };
 
 static int
-delta_apply()
+delta_apply(void)
 {
 	const struct got_error *err = NULL;
 	int i;
@@ -115,8 +115,10 @@ main(int argc, const char *argv[])
 		return 1;
 	}
 
+#ifndef PROFILE
 	if (pledge("stdio rpath wpath cpath", NULL) == -1)
 		err(1, "pledge");
+#endif
 
 	RUN_TEST(delta_apply(), "delta_apply");
 
diff --git a/regress/idset/idset_test.c b/regress/idset/idset_test.c
index ebadf49..7d0f1de 100644
--- a/regress/idset/idset_test.c
+++ b/regress/idset/idset_test.c
@@ -206,8 +206,10 @@ main(int argc, char *argv[])
 	int test_ok = 0, failure = 0;
 	int ch;
 
+#ifndef PROFILE
 	if (pledge("stdio", NULL) == -1)
 		err(1, "pledge");
+#endif
 
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 9b48c7f..7d05f1a 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -458,8 +458,10 @@ main(int argc, char *argv[])
 	const char *repo_path;
 	int ch;
 
+#ifndef PROFILE
 	if (pledge("stdio rpath wpath cpath proc exec sendfd", NULL) == -1)
 		err(1, "pledge");
+#endif
 
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index c6ece3a..1b97298 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -390,9 +390,11 @@ main(int argc, char *argv[])
 	const char *repo_path;
 	int ch;
 
+#ifndef PROFILE
 	if (pledge("stdio rpath wpath cpath flock proc exec sendfd", NULL)
 	    == -1)
 		err(1, "pledge");
+#endif
 
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {