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 390641388C0 for ; Mon, 22 Feb 2016 20:37:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BB2DE21C01A; Mon, 22 Feb 2016 20:37:24 +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 077B521C014 for ; Mon, 22 Feb 2016 20:37:24 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3FE84340B90 for ; Mon, 22 Feb 2016 20:37:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0BC211AE8 for ; Mon, 22 Feb 2016 20:37:19 +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: <1456165040.3d4a141fd4bf94190f9e453304d68b965df85633.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qsize.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 3d4a141fd4bf94190f9e453304d68b965df85633 X-VCS-Branch: master Date: Mon, 22 Feb 2016 20:37:19 +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: dd84879e-c089-48af-b7bc-b9325bca709a X-Archives-Hash: 31d1074133baa4b2992b4419f2d3f306 commit: 3d4a141fd4bf94190f9e453304d68b965df85633 Author: Mike Frysinger gentoo org> AuthorDate: Mon Feb 22 18:17:20 2016 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon Feb 22 18:17:20 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3d4a141f qsize: clean up stat logic a bit By using the *at style func, we can avoid the fixed static buffer and doing a string copy all the time. qsize.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qsize.c b/qsize.c index b9f3afb..2df2fce 100644 --- a/qsize.c +++ b/qsize.c @@ -37,7 +37,6 @@ int qsize_main(int argc, char **argv) q_vdb_cat_ctx *cat_ctx; q_vdb_pkg_ctx *pkg_ctx; size_t i; - struct stat st; char fs_size = 0, summary = 0, summary_only = 0; size_t num_all_files, num_all_nonfiles, num_all_ignored; size_t num_files, num_nonfiles, num_ignored; @@ -46,7 +45,6 @@ int qsize_main(int argc, char **argv) const char *str_disp_units = NULL; size_t buflen; char *buf; - char filename[_Q_PATH_MAX], *filename_root; depend_atom *atom; DECLARE_ARRAY(atoms); DECLARE_ARRAY(ignore_regexp); @@ -81,8 +79,6 @@ int qsize_main(int argc, char **argv) num_all_bytes = num_all_files = num_all_nonfiles = num_all_ignored = 0; - strcpy(filename, portroot); - filename_root = filename + strlen(filename); buflen = _Q_PATH_MAX; buf = xmalloc(buflen); @@ -138,9 +134,9 @@ int qsize_main(int argc, char **argv) continue; if (e->type == CONTENTS_OBJ || e->type == CONTENTS_SYM) { - strcpy(filename_root, e->name); + struct stat st; ++num_files; - if (!lstat(filename, &st)) + if (!fstatat(ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) num_bytes += (fs_size ? st.st_blocks * S_BLKSIZE : st.st_size); } else ++num_nonfiles;