[pacman-dev] [PATCH 2/2] doc: reformat intro to VCS sources to distinguish the grammar

2019-12-24 Thread Eli Schwartz
It's difficult to find it embedded inside a prose paragraph.

Signed-off-by: Eli Schwartz 
---
 doc/PKGBUILD.5.asciidoc | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc
index 27d56a67..b170a812 100644
--- a/doc/PKGBUILD.5.asciidoc
+++ b/doc/PKGBUILD.5.asciidoc
@@ -474,11 +474,13 @@ reference with all of the available functions defined.
 Using VCS Sources[[VCS]]
 
 Building a developmental version of a package using sources from a version
-control system (VCS) is enabled by specifying the source in the form
-`source=('directory::url#fragment?query')`. Currently makepkg supports the
-Bazaar, Git, Subversion, and Mercurial version control systems. For other
-version control systems, manual cloning of upstream repositories must be done
-in the `prepare()` function.
+control system (VCS) is enabled by specifying the source in the form:
+
+   source=('directory::url#fragment?query')
+
+Currently makepkg supports the Bazaar, Git, Subversion, and Mercurial version
+control systems. For other version control systems, manual cloning of upstream
+repositories must be done in the `prepare()` function.
 
 The source URL is divided into four components:
 
-- 
2.24.1


[pacman-dev] [PATCH 1/2] doc: clarify the format of a PKGBUILD source fragment

2019-12-24 Thread Eli Schwartz
Currently, it could be misread to say that a fragment is literally
'commit', rather than 'commit=somehash'. Anecdotally this does not seem
to be obvious to everyone, and rewording it certainly doesn't hurt.

Signed-off-by: Eli Schwartz 
---
 doc/PKGBUILD.5.asciidoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc
index bc5aa011..27d56a67 100644
--- a/doc/PKGBUILD.5.asciidoc
+++ b/doc/PKGBUILD.5.asciidoc
@@ -496,9 +496,9 @@ The source URL is divided into four components:
 
 *fragment*::
(optional) Allows specifying a revision number or branch for makepkg to 
checkout
-   from the VCS. For example, to checkout a given revision, the source 
line would
-   have the format `source=(url#revision=123)`. The available fragments 
depends on
-   the VCS being used:
+   from the VCS. A fragment has the form `type=value`, for example to 
checkout a
+   given revision the source line would be `source=(url#revision=123)`. The
+   available types depends on the VCS being used:
 
*bzr*;;
revision (see `'bzr help revisionspec'` for details)
-- 
2.24.1


[pacman-dev] [PATCH 2/2] Use c99 struct initialization to avoid memset calls

2019-12-24 Thread Dave Reisner
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(, 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(, 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(, 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(, 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(, 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 

[pacman-dev] [PATCHv2 1/2] Ensure regex object is always initialized

2019-12-24 Thread Dave Reisner
This avoids a crash in filetarget_free() when regex support isn't
requested in files_search().
---
v2: Use {0} instead of {}. The former is c99, the latter is a GNU
extension.

 src/pacman/files.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/files.c b/src/pacman/files.c
index 7b0c884b..cae7130d 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -114,7 +114,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
*targets, int regex) {
char *targ = t->data;
size_t len = strlen(targ);
int exact_file = strchr(targ, '/') != NULL;
-   regex_t reg;
+   regex_t reg = {0};
 
if(exact_file) {
while(len > 1 && targ[0] == '/') {
-- 
2.24.1


[pacman-dev] [PATCH] Ensure regex object is always initialized

2019-12-24 Thread Dave Reisner
This avoids a crash in filetarget_free() when regex support isn't
requested in files_search().
---
 src/pacman/files.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/files.c b/src/pacman/files.c
index 7b0c884b..29b593be 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -114,7 +114,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
*targets, int regex) {
char *targ = t->data;
size_t len = strlen(targ);
int exact_file = strchr(targ, '/') != NULL;
-   regex_t reg;
+   regex_t reg = {};
 
if(exact_file) {
while(len > 1 && targ[0] == '/') {
-- 
2.24.1