Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Nuke 3rd argument to pkg_open()
Matthew Seaman committed 13 years ago
commit 20badeddf324cfdc0af47deddaaa62cf30e0dfa9
parent a08169f
10 files changed +16 -26
modified libpkg/pkg.c
@@ -947,13 +947,13 @@ pkg_list_free(struct pkg *pkg, pkg_list list) {
}

int
-
pkg_open(struct pkg **pkg_p, const char *path, struct sbuf *mbuf)
+
pkg_open(struct pkg **pkg_p, const char *path)
{
	struct archive *a;
	struct archive_entry *ae;
	int ret;

-
	ret = pkg_open2(pkg_p, &a, &ae, path, mbuf);
+
	ret = pkg_open2(pkg_p, &a, &ae, path);

	if (ret != EPKG_OK && ret != EPKG_END)
		return (EPKG_FATAL);
@@ -964,13 +964,13 @@ pkg_open(struct pkg **pkg_p, const char *path, struct sbuf *mbuf)
}

int
-
pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, const char *path, struct sbuf *mbuf)
+
pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, const char *path)
{
	struct pkg *pkg;
	pkg_error_t retcode = EPKG_OK;
	int ret;
	int64_t size;
-
	struct sbuf *manifest = mbuf;
+
	struct sbuf *manifest;
	const char *fpath;
	char buf[BUFSIZ];
	struct sbuf **sbuf;
@@ -986,7 +986,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, con

	assert(path != NULL && path[0] != '\0');

-
	sbuf_init(&manifest);
+
	manifest = sbuf_new_auto();

	*a = archive_read_new();
	archive_read_support_compression_all(*a);
@@ -1060,10 +1060,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, con
	}

	cleanup:
-
	if (mbuf == NULL)
-
		sbuf_delete(manifest);
-
	else
-
		sbuf_clear(manifest);
+
	sbuf_delete(manifest);

	if (retcode != EPKG_OK && retcode != EPKG_END) {
		if (*a != NULL)
modified libpkg/pkg.h
@@ -346,7 +346,7 @@ int pkg_is_valid(struct pkg *);
 * NULL pointer, the function allocate a new pkg using pkg_new().
 * @param path The path to the local package archive.
 */
-
int pkg_open(struct pkg **p, const char *path, struct sbuf *mbuf);
+
int pkg_open(struct pkg **p, const char *path);

/**
 * @return the type of the package.
modified libpkg/pkg_add.c
@@ -142,7 +142,7 @@ pkg_add(struct pkgdb *db, const char *path, int flags)
	 * current archive_entry to the first non-meta file.
	 * If there is no non-meta files, EPKG_END is returned.
	 */
-
	ret = pkg_open2(&pkg, &a, &ae, path, NULL);
+
	ret = pkg_open2(&pkg, &a, &ae, path);
	if (ret == EPKG_END)
		extract = false;
	else if (ret != EPKG_OK) {
modified libpkg/pkg_jobs.c
@@ -236,7 +236,7 @@ pkg_jobs_install(struct pkg_jobs *j, bool force)
		}
		snprintf(path, sizeof(path), "%s/%s", cachedir, pkgrepopath);

-
		pkg_open(&newpkg, path, NULL);
+
		pkg_open(&newpkg, path);
		if (newversion != NULL) {
			pkg_emit_upgrade_begin(p);
		} else {
@@ -334,7 +334,6 @@ pkg_jobs_fetch(struct pkg_jobs *j)
{
	struct pkg *p = NULL;
	struct pkg *pkg = NULL;
-
	struct sbuf *buf = NULL;
	struct statfs fs;
	struct stat st;
	char path[MAXPATHLEN + 1];
@@ -390,15 +389,13 @@ pkg_jobs_fetch(struct pkg_jobs *j)
	/* integrity checking */
	pkg_emit_integritycheck_begin();

-
	buf = sbuf_new_auto();
	while (pkg_jobs(j, &p) == EPKG_OK) {
		const char *pkgrepopath;

		pkg_get(p, PKG_REPOPATH, &pkgrepopath);
		snprintf(path, sizeof(path), "%s/%s", cachedir,
		    pkgrepopath);
-
		if (pkg_open(&pkg, path, buf) != EPKG_OK) {
-
			sbuf_delete(buf);
+
		if (pkg_open(&pkg, path) != EPKG_OK) {
			return (EPKG_FATAL);
		}

@@ -407,7 +404,6 @@ pkg_jobs_fetch(struct pkg_jobs *j)
	}

	pkg_free(pkg);
-
	sbuf_delete(buf);

	if (pkgdb_integrity_check(j->db) != EPKG_OK || ret != EPKG_OK)
		return (EPKG_FATAL);
modified libpkg/pkg_repo.c
@@ -838,7 +838,6 @@ read_pkg_file(void *data)
	off_t st_size;
	int fts_info;

-
	struct sbuf *manifest = sbuf_new_auto();
	char *ext = NULL;
	char *pkg_path;

@@ -896,7 +895,7 @@ read_pkg_file(void *data)

		sha256_file(fts_accpath, r->cksum);

-
		if (pkg_open(&r->pkg, fts_accpath, manifest) != EPKG_OK) {
+
		if (pkg_open(&r->pkg, fts_accpath) != EPKG_OK) {
			r->retcode = EPKG_WARN;
		}

@@ -915,8 +914,6 @@ read_pkg_file(void *data)
	d->thd_finished++;
	pthread_cond_signal(&d->has_result);
	pthread_mutex_unlock(&d->results_m);
-

-
	sbuf_free(manifest);
}

int
modified libpkg/private/pkg.h
@@ -196,7 +196,7 @@ int pkg_script_run(struct pkg *, pkg_script type);
int pkg_add_user_group(struct pkg *pkg);
int pkg_delete_user_group(struct pkgdb *db, struct pkg *pkg);

-
int pkg_open2(struct pkg **p, struct archive **a, struct archive_entry **ae, const char *path, struct sbuf *mbuf);
+
int pkg_open2(struct pkg **p, struct archive **a, struct archive_entry **ae, const char *path);

void pkg_list_free(struct pkg *, pkg_list);

modified pkg/add.c
@@ -108,7 +108,7 @@ exec_add(int argc, char **argv)

		}
			
-
		pkg_open(&p, file, NULL);
+
		pkg_open(&p, file);

		if ((retcode = pkg_add(db, file, 0)) != EPKG_OK) {
			sbuf_cat(failedpkgs, argv[i]);
modified pkg/clean.c
@@ -89,7 +89,7 @@ exec_clean(int argc, char **argv)
		if (repopath[0] == '/')
			repopath++;

-
		if (pkg_open(&pkg, ent->fts_path, NULL) != EPKG_OK) {
+
		if (pkg_open(&pkg, ent->fts_path) != EPKG_OK) {
			warnx("skipping %s", ent->fts_path);
			continue;
		}
modified pkg/info.c
@@ -181,7 +181,7 @@ exec_info(int argc, char **argv)
	}

	if (file != NULL) {
-
		if (pkg_open(&pkg, file, NULL) != EPKG_OK) {
+
		if (pkg_open(&pkg, file) != EPKG_OK) {
			return (1);
		}
		print_info(pkg, opt);
modified pkg/query.c
@@ -821,7 +821,7 @@ exec_query(int argc, char **argv)
		return (EX_USAGE);

	if (pkgname != NULL) {
-
		if (pkg_open(&pkg, pkgname, NULL) != EPKG_OK) {
+
		if (pkg_open(&pkg, pkgname) != EPKG_OK) {
			return (EX_IOERR);
		}