Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Replace each call of warn(x) to an event.
jlaffaye committed 14 years ago
commit 146165ab77db20298aa9d4717c02c7348571c8b2
parent 1a80a52
12 files changed +45 -42
modified libpkg/packing.c
@@ -1,18 +1,12 @@
-
#include <fcntl.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
-
#include <sys/sbuf.h>
-
#include <fts.h>

#include <archive.h>
#include <archive_entry.h>
-

-
#include <err.h>
-
#include <errno.h>
-
#include <stdio.h>
+
#include <fcntl.h>
+
#include <fts.h>
#include <string.h>
-
#include <stdlib.h>

#include "pkg.h"
#include "pkg_event.h"
@@ -240,6 +234,6 @@ packing_format_from_string(const char *str)
		return TGZ;
	if (strcmp(str, "tar") == 0)
		return TAR;
-
	warnx("unknown format %s, using txz", str);
+
	EMIT_PKG_ERROR("unknown format %s, using txz", str);
	return TXZ;
}
modified libpkg/pkg.c
@@ -1,6 +1,5 @@
#include <archive.h>
#include <archive_entry.h>
-
#include <err.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
@@ -132,7 +131,7 @@ pkg_get(struct pkg const * const pkg, const pkg_attr attr)
	}

	if ((pkg->fields[attr].type & pkg->type) == 0)
-
		errx(EX_SOFTWARE, "wrong usage of `attr` for this type of `pkg`");
+
		EMIT_PKG_ERROR("%s", "wrong usage of `attr` for this type of `pkg`");

	return (sbuf_get(pkg->fields[attr].value));
}
@@ -498,7 +497,7 @@ pkg_adddir(struct pkg *pkg, const char *path)

	while (pkg_dirs(pkg, &d) == EPKG_OK) {
		if (strcmp(path, pkg_dir_path(d)) == 0) {
-
			warnx("Duplicate directory listing: %s, ignoring", path);
+
			EMIT_PKG_ERROR("Duplicate directory listing: %s, ignoring", path);
			return (EPKG_OK);
		}
	}
modified libpkg/pkg_attributes.c
@@ -1,7 +1,7 @@
-
#include <err.h>
#include <stdlib.h>

#include "pkg.h"
+
#include "pkg_event.h"
#include "pkg_private.h"

/*
@@ -106,10 +106,12 @@ pkg_dir_path(struct pkg_dir *d)
int
pkg_conflict_new(struct pkg_conflict **c)
{
-
	if ((*c = calloc(1, sizeof(struct pkg_conflict))) == NULL)
-
		err(EXIT_FAILURE, "calloc()");
+
	if ((*c = calloc(1, sizeof(struct pkg_conflict))) == NULL) {
+
		EMIT_ERRNO("calloc", "pkg_conflict");
+
		return (EPKG_FATAL);
+
	}

-
	return (0);
+
	return (EPKG_OK);
}

void
@@ -135,10 +137,12 @@ pkg_conflict_glob(struct pkg_conflict *c)
int
pkg_script_new(struct pkg_script **script)
{
-
	if ((*script = calloc(1, sizeof(struct pkg_script))) == NULL)
-
		err(EXIT_FAILURE, "calloc()");
+
	if ((*script = calloc(1, sizeof(struct pkg_script))) == NULL) {
+
		EMIT_ERRNO("calloc", "pkg_script");
+
		return (EPKG_FATAL);
+
	}

-
	return (0);
+
	return (EPKG_OK);
}

void
modified libpkg/pkg_create.c
@@ -2,7 +2,6 @@

#include <archive.h>
#include <archive_entry.h>
-
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <glob.h>
modified libpkg/pkg_delete.c
@@ -1,10 +1,10 @@
+
#include <sys/stat.h>
+
#include <sys/types.h>
+

+
#include <errno.h>
#include <string.h>
-
#include <err.h>
#include <unistd.h>
#include <stdlib.h>
-
#include <errno.h>
-
#include <sys/types.h>
-
#include <sys/stat.h>

#include "pkg.h"
#include "pkg_event.h"
modified libpkg/pkg_elf.c
@@ -5,9 +5,9 @@
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
-
#include <err.h>

#include "pkg.h"
+
#include "pkg_event.h"
#include "pkg_private.h"

static int
@@ -72,7 +72,7 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
						found = true;
				}
				if (!found) {
-
					warnx("adding forgotten depends (%s): %s-%s", map->l_name, pkg_get(p, PKG_NAME), pkg_get(p, PKG_VERSION));
+
					EMIT_PKG_ERROR("adding forgotten depends (%s): %s-%s", map->l_name, pkg_get(p, PKG_NAME), pkg_get(p, PKG_VERSION));
					pkg_adddep(pkg, pkg_get(p, PKG_NAME), pkg_get(p, PKG_ORIGIN), pkg_get(p, PKG_VERSION));
				}
			}
modified libpkg/pkg_jobs.c
@@ -1,5 +1,4 @@
#include <assert.h>
-
#include <err.h>
#include <stdlib.h>
#include <string.h>

@@ -18,8 +17,10 @@ pkg_jobs_new(struct pkg_jobs **j, pkg_jobs_t t, struct pkgdb *db)
	if (t == PKG_JOBS_INSTALL && db->type != PKGDB_REMOTE)
		return (ERROR_BAD_ARG("db"));

-
	if((*j = calloc(1, sizeof(struct pkg_jobs))) == NULL)
-
		err(1, "calloc()");
+
	if((*j = calloc(1, sizeof(struct pkg_jobs))) == NULL) {
+
		EMIT_ERRNO("calloc", "pkg_jobs");
+
		return (EPKG_FATAL);
+
	}

	STAILQ_INIT(&(*j)->jobs);
	LIST_INIT(&(*j)->nodes);
@@ -180,8 +181,9 @@ add_dep(struct pkg_jobs *j, struct pkg_jobs_node *n)
		if (ndep->pkg == NULL) {
			ndep->pkg = pkgdb_query_remote(j->db, pkg_dep_origin(dep));
			if (ndep->pkg == NULL)
-
				err(1, "%s", pkg_error_string());
-
			add_dep(j, ndep);
+
				EMIT_MISSING_DEP(n->pkg, dep);
+
			else
+
				add_dep(j, ndep);
		}
		add_parent(ndep, n);
	}
modified libpkg/pkg_manifest.c
@@ -3,7 +3,6 @@

#include <assert.h>
#include <ctype.h>
-
#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -108,7 +107,10 @@ parse_mapping(struct pkg *pkg, yaml_node_pair_t *pair, yaml_document_t *document
				else if (!strcasecmp(subkey->data.scalar.value, "version"))
					strlcpy(version, subval->data.scalar.value, BUFSIZ);
				else
-
					warnx("Ignoring key: (%s: %s) for dependency %s",subkey->data.scalar.value,subval->data.scalar.value, key->data.scalar.value);
+
					EMIT_PKG_ERROR("Ignoring key: (%s: %s) for dependency %s",
+
								   subkey->data.scalar.value,
+
								   subval->data.scalar.value,
+
								   key->data.scalar.value);
				++subpair;
			}
			pkg_adddep(pkg, key->data.scalar.value, origin, version);
@@ -140,16 +142,21 @@ parse_mapping(struct pkg *pkg, yaml_node_pair_t *pair, yaml_document_t *document
			type = manifest_type(key->data.scalar.value);
			if (type == -1) {
				if (val->type == YAML_SCALAR_NODE)
-
					warnx("Unknown line: (%s: %s)\n", key->data.scalar.value, val->data.scalar.value);
+
					EMIT_PKG_ERROR("Unknown line: (%s: %s)\n",
+
								   key->data.scalar.value,
+
								   val->data.scalar.value);
				else
-
					warnx("Unknown key: (%s)\n", key->data.scalar.value);
+
					EMIT_PKG_ERROR("Unknown key: (%s)\n",
+
								   key->data.scalar.value);
				++pair;
				break;
			}
			if (val->type == YAML_SCALAR_NODE) {
				type = manifest_type(key->data.scalar.value);
				if (type == -1) {
-
					warnx("Unknown line: (%s: %s)\n", key->data.scalar.value, val->data.scalar.value);
+
					EMIT_PKG_ERROR("Unknown line: (%s: %s)\n",
+
								   key->data.scalar.value,
+
								   val->data.scalar.value);
				} else if (type == PKG_FLATSIZE)
					pkg_setflatsize(pkg, strtoimax(val->data.scalar.value, NULL, 10));
				else
modified libpkg/pkg_ports.c
@@ -1,12 +1,12 @@
#include <sys/stat.h>

-
#include <err.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#include "pkg.h"
+
#include "pkg_event.h"
#include "pkg_error.h"
#include "pkg_private.h"

@@ -146,7 +146,7 @@ ports_parse_plist(struct pkg *pkg, char *plist)
				ret += pkg_adddir(pkg, path);

			} else {
-
				warnx("%s is deprecated, ignoring", plist_p);
+
				EMIT_PKG_ERROR("%s is deprecated, ignoring", plist_p);
			}
		} else if ((len = strlen(plist_p)) > 0){
			buf = plist_p;
@@ -175,7 +175,7 @@ ports_parse_plist(struct pkg *pkg, char *plist)
				}
				ret += pkg_addfile(pkg, path, p);
			} else {
-
				warn("lstat(%s)", path);
+
				EMIT_ERRNO("lstat", path);
			}
		}

modified libpkg/pkg_util.c
@@ -4,7 +4,6 @@

#include <assert.h>
#include <dirent.h>
-
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
modified libpkg/pkg_version.c
@@ -1,7 +1,7 @@
+
#include <err.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
-
#include <err.h>
#include "pkg.h"

/*
modified libpkg/pkgdb.c
@@ -3,7 +3,6 @@
#include <sys/types.h>

#include <assert.h>
-
#include <err.h>
#include <errno.h>
#include <regex.h>
#include <stdlib.h>