Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Revert "cleanup: replace memset with some inline declaration"
Baptiste Daroussin committed 3 years ago
commit 991ca6b6349a4a85220b775fb04095eeddc03403
parent 25b89d7
8 files changed +28 -14
modified libpkg/dns_utils.c
@@ -276,14 +276,16 @@ set_nameserver(const char *nsname) {
#ifndef HAVE___RES_SETSERVERS
	return (-1);
#else
-
	struct __res_state res = { 0 };
+
	struct __res_state res;
	union res_sockaddr_union u[MAXNS];
	struct addrinfo *answer = NULL;
	struct addrinfo *cur = NULL;
-
	struct addrinfo hint = { 0 };
+
	struct addrinfo hint;
	int nscount = 0;

	memset(u, 0, sizeof(u));
+
	memset(&hint, 0, sizeof(hint));
+
	memset(&res, 0, sizeof(res));
	hint.ai_socktype = SOCK_DGRAM;
	hint.ai_flags = AI_NUMERICHOST;

modified libpkg/fetch_ssh.c
@@ -57,12 +57,13 @@ tcp_connect(struct pkg_repo *repo, struct url *u)
{
	char *line = NULL;
	size_t linecap = 0;
-
	struct addrinfo *ai = NULL, *curai, hints = { 0 };
+
	struct addrinfo *ai = NULL, *curai, hints;
	char srv[NI_MAXSERV];
	int sd = -1;
	int retcode;

	pkg_debug(1, "TCP> tcp_connect");
+
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = PF_UNSPEC;
	if ((repo->flags & REPO_FLAGS_USE_IPV4) == REPO_FLAGS_USE_IPV4)
		hints.ai_family = PF_INET;
@@ -327,11 +328,13 @@ static int
ssh_writev(int fd, struct iovec *iov, int iovcnt)
{
	struct timeval now, timeout, delta;
-
	struct pollfd pfd = { 0 };
+
	struct pollfd pfd;
	ssize_t wlen, total;
	int deltams;
	struct msghdr msg;

+
	memset(&pfd, 0, sizeof pfd);
+

	if (fetchTimeout) {
		pfd.fd = fd;
		pfd.events = POLLOUT | POLLERR;
modified libpkg/pkg_config.c
@@ -512,7 +512,7 @@ static void pkg_repo_free(struct pkg_repo *r);
static void
connect_evpipe(const char *evpipe) {
	struct stat st;
-
	struct sockaddr_un sock = { 0 };
+
	struct sockaddr_un sock;
	int flag = O_WRONLY;

	if (stat(evpipe, &st) != 0) {
@@ -537,6 +537,7 @@ connect_evpipe(const char *evpipe) {
			pkg_emit_errno("Open event pipe", evpipe);
			return;
		}
+
		memset(&sock, 0, sizeof(struct sockaddr_un));
		sock.sun_family = AF_UNIX;
		if (strlcpy(sock.sun_path, evpipe, sizeof(sock.sun_path)) >=
		    sizeof(sock.sun_path)) {
@@ -1000,7 +1001,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
	bool fatal_errors = false;
	int conffd = -1;
	char *tmp = NULL;
-
	struct os_info oi = { 0 };
+
	struct os_info oi;
	size_t ukeylen;
	int err = EPKG_OK;

@@ -1012,6 +1013,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
		return (EPKG_FATAL);
	}

+
	memset(&oi, 0, sizeof(oi));
	pkg_get_myarch(myabi, BUFSIZ, &oi);
	pkg_get_myarch_legacy(myabi_legacy, BUFSIZ);
#ifdef __FreeBSD__
modified libpkg/pkg_cudf.c
@@ -442,7 +442,9 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
{
	char *line = NULL, *begin, *param, *value;
	size_t linecap = 0;
-
	struct pkg_cudf_entry cur_pkg = { 0 };
+
	struct pkg_cudf_entry cur_pkg;
+

+
	memset(&cur_pkg, 0, sizeof(cur_pkg));

	while (getline(&line, &linecap, f) > 0) {
		/* Split line, cut spaces */
modified libpkg/pkg_elf.c
@@ -827,7 +827,7 @@ pkg_get_myarch_elfparse(char *dest, size_t sz, struct os_info *oi)
	int ret = EPKG_OK;
	const char *arch, *abi, *endian_corres_str, *wordsize_corres_str, *fpu;
	bool checkroot;
-
	struct os_info loi = { 0 };
+
	struct os_info loi;

	const char *abi_files[] = {
		getenv("ABI_FILE"),
@@ -837,8 +837,10 @@ pkg_get_myarch_elfparse(char *dest, size_t sz, struct os_info *oi)

	arch = NULL;

-
	if (oi == NULL)
+
	if (oi == NULL) {
+
		memset(&loi, 0, sizeof(loi));
		oi = &loi;
+
	}

	if (elf_version(EV_CURRENT) == EV_NONE) {
		pkg_emit_error("ELF library initialization failed: %s",
modified libpkg/pkg_repo_create.c
@@ -325,10 +325,11 @@ static void
tell_parent(int fd, char *buf, size_t len)
{
	struct iovec iov[2];
-
	struct msghdr msg = { 0 };
+
	struct msghdr msg;

	iov[0].iov_base = buf;
	iov[0].iov_len = len;
+
	memset(&msg, 0, sizeof(msg));
	msg.msg_iov = iov;
	msg.msg_iovlen = 1;
	sendmsg(fd, &msg, MSG_EOR);
modified libpkg/scripts.c
@@ -265,12 +265,13 @@ cleanup:


int
-
pkg_script_run_child(int pid, int *pstat, int inputfd, const char* script_name)
-
{
-
	struct pollfd pfd = { 0 };
+
pkg_script_run_child(int pid, int *pstat, int inputfd, const char* script_name) {
+
	struct pollfd pfd;
	bool wait_for_child;
	char msgbuf[16384+1];

+

+
	memset(&pfd, 0, sizeof(pfd));
	pfd.events = POLLIN | POLLERR | POLLHUP;
	pfd.fd = inputfd;

modified src/utils.c
@@ -937,11 +937,12 @@ print_jobs_summary(struct pkg_jobs *jobs, const char *msg, ...)
	struct pkg_solved_display **displays;
	bool first = true;
	size_t bytes_change, limbytes;
-
	struct jobs_sum_number sum = { 0 };
+
	struct jobs_sum_number sum;

	dlsize = oldsize = newsize = 0;
	type = pkg_jobs_type(jobs);
	memset(disp, 0, sizeof(*disp) * PKG_DISPLAY_MAX);
+
	memset(&sum, 0, sizeof(sum));

	nbtodl = 0;
	while (pkg_jobs_iter(jobs, &iter, &new_pkg, &old_pkg, &type)) {