commit: 0feba3c91ca51bc68f5ba8688c91f772d81cb0ce Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Mon Jun 20 03:02:15 2016 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> 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)