This is guaranteed less error prone than calling memset and hoping the
human gets the argument order correct.
---
lib/libalpm/be_local.c | 5 +
lib/libalpm/be_package.c | 7 ++-
lib/libalpm/be_sync.c| 7 ++-
lib/libalpm/dload.c | 13 ++---
lib/libalpm/signing.c| 23 +++
lib/libalpm/util.c | 2 +-
src/pacman/conf.c| 3 +--
7 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index b89acf05..78e32a24 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -694,7 +694,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t
*info,
static int local_db_read(alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
- char line[1024];
+ char line[1024] = {0};
alpm_db_t *db = info->origin_data.db;
/* bitmask logic here:
@@ -717,9 +717,6 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
"loading package data for %s : level=0x%x\n",
info->name, inforeq);
- /* clear out 'line', to be certain - and to make valgrind happy */
- memset(line, 0, sizeof(line));
-
/* DESC */
if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
char *path = _alpm_local_db_pkgpath(db, info, "desc");
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) {
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 2c76fe83..4614610c 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -219,12 +219,10 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
for(i = db->servers; i; i = i->next) {
const char *server = i->data, *final_db_url = NULL;
- struct dload_payload payload;
+ struct dload_payload payload = {};
size_t len;
int sig_ret = 0;
- memset(&payload, 0, sizeof(struct dload_payload));
-
/* set hard upper limit of 25MiB */
payload.max_size = 25 * 1024 * 1024;
@@ -601,7 +599,7 @@ static int sync_db_read(alpm_db_t *db, struct archive
*archive,
{
const char *entryname, *filename;
alpm_pkg_t *pkg;
- struct archive_read_buffer buf;
+ struct archive_read_buffer buf = {0};
entryname = archive_entry_pathname(entry);
if(entryname == NULL) {
@@ -613,7 +611,6 @@ static int sync_db_read(alpm_db_t *db, struct archive
*archive,
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "loading package data from
archive entry %s\n",
entryname);
- memset(&buf, 0, sizeof(buf));
/* 512K for a line length seems reasonable */
buf.max_line_size = 512 * 1024;
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 40a1d07d..b3e6a411 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -195,9 +195,10 @@ static int curl_gethost(const char *url, char *buffer,
size_t buf_len)
static int utimes_long(const char *path, long seconds)
{
if(seconds != -1) {
- struct timeval tv[2];
- memset(&tv, 0, sizeof(tv));
- tv[0].tv_sec = tv[1].tv_sec = seconds;
+ struct timeval tv[2] = {
+ { .tv_sec = seconds, },
+ { .tv_sec = seconds, },
+ };
return utimes(path, tv);
}
return 0;
@@ -657,7 +658,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle,
const char *url)
char *filepath;
const char *cachedir, *final_pkg_url = NULL;
char *final_file = NULL;
- struct dload_payload payload;
+ struct dload_payload payload = {0};
int ret = 0;
CHECK_HANDLE(handle, retu