Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/dload.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2019-12-24 10:28:11 -0500
committerAllan McRae <allan@archlinux.org>2020-01-07 11:40:32 +1000
commit9883015be2b2010ad541fd02b6856bfdb28fb35d (patch)
treecea21e7bc4eab89a47356f60c4b924ae3043bb42 /lib/libalpm/dload.c
parentffb69c700abd6eb3b86e79e09b135029ff9104b4 (diff)
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.
Diffstat (limited to 'lib/libalpm/dload.c')
-rw-r--r--lib/libalpm/dload.c13
1 files changed, 6 insertions, 7 deletions
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, return NULL);
@@ -666,8 +667,6 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
/* find a valid cache dir to download to */
cachedir = _alpm_filecache_setup(handle);
- memset(&payload, 0, sizeof(struct dload_payload));
-
/* attempt to find the file in our pkgcache */
filepath = filecache_find_url(handle, url);
if(filepath == NULL) {
@@ -740,7 +739,7 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
FREE(payload->destfile_name);
FREE(payload->content_disp_name);
FREE(payload->fileurl);
- memset(payload, '\0', sizeof(*payload));
+ *payload = (struct dload_payload){0};
}
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload)