From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5AB4D1388C1 for ; Sat, 28 Nov 2015 02:44:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2FE0D21C013; Sat, 28 Nov 2015 02:44:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9E7DA21C013 for ; Sat, 28 Nov 2015 02:44:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 32F9934063E for ; Sat, 28 Nov 2015 02:44:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BF195E6B for ; Sat, 28 Nov 2015 02:44:34 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1448654558.c1a168f95699da8d2ac659cb6ea0c7fb3f4c0df9.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qcache.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: c1a168f95699da8d2ac659cb6ea0c7fb3f4c0df9 X-VCS-Branch: master Date: Sat, 28 Nov 2015 02:44:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 7cb84636-f3aa-4992-9d1f-b70c0b695f61 X-Archives-Hash: d1157e6651124465c5322b590bf95ebe commit: c1a168f95699da8d2ac659cb6ea0c7fb3f4c0df9 Author: Mike Frysinger gentoo org> AuthorDate: Fri Nov 27 20:02:38 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Fri Nov 27 20:02:38 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c1a168f9 qcache: use xasprintf instead of alloc+snprintf qcache.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/qcache.c b/qcache.c index 5d915bd..9e41c3c 100644 --- a/qcache.c +++ b/qcache.c @@ -537,9 +537,7 @@ int qcache_traverse(void (*func)(qcache_data*)) /* traverse packages */ for (j = 0; j < num_pkg; j++) { - len = sizeof(char) * (strlen(portdir) + strlen("/") + strlen(categories[i]->d_name) + strlen("/") + strlen(packages[j]->d_name) + 1); - ebuildpath = xzalloc(len); - snprintf(ebuildpath, len, "%s/%s/%s", portdir, categories[i]->d_name, packages[j]->d_name); + xasprintf(&ebuildpath, "%s/%s/%s", portdir, categories[i]->d_name, packages[j]->d_name); if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds, qcache_ebuild_select, qcache_vercmp))) { warnp("%s", ebuildpath); @@ -561,10 +559,8 @@ int qcache_traverse(void (*func)(qcache_data*)) /* traverse ebuilds */ for (k = 0; k < num_ebuild; k++) { - len = sizeof(char) * (strlen(catpath) + strlen("/") + strlen(categories[i]->d_name) + strlen("/") + strlen(ebuilds[k]->d_name) + 1); - cachepath = xzalloc(len); - snprintf(cachepath, len, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name); - cachepath[len-8] = '\0'; /* remove ".ebuild" */ + len = xasprintf(&cachepath, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name); + cachepath[len - 7] = '\0'; /* remove ".ebuild" */ data.category = categories[i]->d_name; data.package = packages[j]->d_name; @@ -886,12 +882,9 @@ _q_static int qcache_init(void) { char *filename; - unsigned int len; + int len; - len = sizeof(char) * (strlen(portdir) + strlen("/profiles/arch.list") + 1); - filename = xzalloc(len); - - snprintf(filename, len, "%s/profiles/arch.list", portdir); + xasprintf(&filename, "%s/profiles/arch.list", portdir); if (NULL == (archlist = qcache_read_lines(filename))) { free(filename);