From 9883015be2b2010ad541fd02b6856bfdb28fb35d Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 24 Dec 2019 10:28:11 -0500 Subject: Use c99 struct initialization to avoid memset calls This is guaranteed less error prone than calling memset and hoping the human gets the argument order correct. --- lib/libalpm/be_package.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/libalpm/be_package.c') diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 5ffea875..9a8b4410 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -164,9 +164,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t * char *ptr = NULL; char *key = NULL; int ret, linenum = 0; - struct archive_read_buffer buf; + struct archive_read_buffer buf = {0}; - memset(&buf, 0, sizeof(buf)); /* 512K for a line length seems reasonable */ buf.max_line_size = 512 * 1024; @@ -448,13 +447,11 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str char *mtree_data = NULL; struct archive *mtree; struct archive_entry *mtree_entry = NULL; - alpm_filelist_t filelist; + alpm_filelist_t filelist = {0}; _alpm_log(handle, ALPM_LOG_DEBUG, "found mtree for package %s, getting file list\n", pkg->filename); - memset(&filelist, 0, sizeof(alpm_filelist_t)); - /* create a new archive to parse the mtree and load it from archive into memory */ /* TODO: split this into a function */ if((mtree = archive_read_new()) == NULL) { -- cgit v1.2.3-24-g4f1b