Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Use ARRAY_INIT macro instead of using bzero to init the array structure.
jlaffaye committed 15 years ago
commit 565657fbbdbc62ce7d04d395098513ca6d2c8d80
parent 207fe90674b14a08fe9e287ef381ec06bc3621ad
3 files changed +7 -6
modified libpkg/pkg.c
@@ -594,13 +594,13 @@ pkg_addfile(struct pkg *pkg, const char *path, const char *sha256)
	if (path == NULL || path[0] == '\0')
		return (ERROR_BAD_ARG("path"));

+
	if (sha256 == NULL || strlen(sha256) != 64)
+
		return (ERROR_BAD_ARG("sha256"));
+

	pkg_file_new(&file);

	strlcpy(file->path, path, sizeof(file->path));
-

-
	/* TODO: when is it not required? - jlaffaye */
-
	if (sha256 != NULL)
-
		strlcpy(file->sha256, sha256, sizeof(file->sha256));
+
	strlcpy(file->sha256, sha256, sizeof(file->sha256));

	array_init(&pkg->files, 10);
	array_append(&pkg->files, file);
modified libpkg/pkg_delete.c
@@ -33,7 +33,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
	const char *mtree = NULL;
	struct archive *a;
	struct archive_entry *ae;
-
	struct array mtreedirs;
+
	struct array mtreedirs = ARRAY_INIT;
	const char *prefix;
	char *path, *end, *fullpath;
	struct sbuf *script_cmd;
@@ -88,7 +88,6 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
	if (archive_read_open_memory(a, strdup(mtree), strlen(mtree)) != ARCHIVE_OK)
		return (pkg_error_set(EPKG_FATAL, "mtree: %s", archive_error_string(a)));

-
	bzero(&mtreedirs, sizeof(mtreedirs));
	array_init(&mtreedirs, 20);

	while ((ret = archive_read_next_header(a, &ae)) == ARCHIVE_OK)
modified libpkg/pkg_util.h
@@ -4,6 +4,8 @@
#include <sys/types.h>
#include <sys/sbuf.h>

+
#define ARRAY_INIT {0, 0, NULL}
+

struct array {
	size_t cap;
	size_t len;