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 DE8171382AC for ; Mon, 20 Jun 2016 03:08:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E73D094083; Mon, 20 Jun 2016 03:08:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 96F7F1425B for ; Mon, 20 Jun 2016 03:08:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B7E44340906 for ; Mon, 20 Jun 2016 03:08:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2C5352422 for ; Mon, 20 Jun 2016 03:08:22 +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: <1466391735.0feba3c91ca51bc68f5ba8688c91f772d81cb0ce.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: paxmacho.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 0feba3c91ca51bc68f5ba8688c91f772d81cb0ce X-VCS-Branch: master Date: Mon, 20 Jun 2016 03:08:22 +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: ca9ce557-24a3-4c8c-9f07-5ffb077c36a4 X-Archives-Hash: 06213534c0ec923f78ad11799ad244b8 commit: 0feba3c91ca51bc68f5ba8688c91f772d81cb0ce Author: Mike Frysinger gentoo org> AuthorDate: Mon Jun 20 03:02:15 2016 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon Jun 20 03:02:15 2016 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=0feba3c9 paxmacho: simplify readmacho a bit The readmacho_fd helper will already use fstat on the fd if we pass in a length of 0, so let that work rather than do stat/open since there is a minor race there. paxmacho.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/paxmacho.c b/paxmacho.c index 090fc18..142af6e 100644 --- a/paxmacho.c +++ b/paxmacho.c @@ -189,16 +189,12 @@ inline static uint32_t read_mach_header(fatobj *fobj, void *addr) * arch. */ fatobj *readmacho(const char *filename) { - struct stat st; int fd; - if (stat(filename, &st) == -1) - return NULL; - if ((fd = open(filename, O_RDONLY)) == -1) return NULL; - return readmacho_fd(filename, fd, st.st_size); + return readmacho_fd(filename, fd, 0); } fatobj *readmacho_fd(const char *filename, int fd, size_t len)