From ec67cded1d2969b5ba21028f0dd1560827947f3d Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 1 Jul 2014 17:20:06 -0700 Subject: [PATCH] Quiten warnings in fts.c. Also bring us closer to upstream. Sadly the Linux and BSD dirent structs don't match, so we'll never be completely in sync (and I don't think we can hide the difference with macro trickery). Change-Id: Ief4275856116cd1d5b5e0f9166db1ead9439515c --- libc/bionic/fts.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libc/bionic/fts.c b/libc/bionic/fts.c index ec0baf75a..c491b6a0b 100644 --- a/libc/bionic/fts.c +++ b/libc/bionic/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.43 2009/08/27 16:19:27 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.46 2014/05/25 17:47:04 tedu Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -97,7 +98,7 @@ fts_open(char * const *argv, int options, * Start out with 1K of path space, and enough, in any case, * to hold the user's paths. */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) + if (fts_palloc(sp, MAX(fts_maxarglen(argv), PATH_MAX))) goto mem1; /* Allocate/initialize root's parent. */ @@ -447,7 +448,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); */ /* ARGSUSED */ int -fts_set(FTS *sp, FTSENT *p, int instr) +fts_set(FTS *sp __unused, FTSENT *p, int instr) { if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW && instr != FTS_NOINSTR && instr != FTS_SKIP) { @@ -637,7 +638,7 @@ fts_build(FTS *sp, int type) maxlen = sp->fts_pathlen - len; /* - * fts_level is a short so we must prevent it from wrapping + * fts_level is signed so we must prevent it from wrapping * around to FTS_ROOTLEVEL and FTS_ROOTPARENTLEVEL. */ level = cur->fts_level; @@ -908,10 +909,9 @@ fts_alloc(FTS *sp, char *name, size_t namelen) len = sizeof(FTSENT) + namelen; if (!ISSET(FTS_NOSTAT)) len += sizeof(struct stat) + ALIGNBYTES; - if ((p = malloc(len)) == NULL) + if ((p = calloc(1, len)) == NULL) return (NULL); - memset(p, 0, len); p->fts_path = sp->fts_path; p->fts_namelen = namelen; p->fts_instr = FTS_NOINSTR; @@ -936,7 +936,7 @@ fts_lfree(FTSENT *head) /* * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even + * Most systems will allow creation of paths much longer than PATH_MAX, even * though the kernel won't resolve them. Add the size (not just what's needed) * plus 256 bytes so don't realloc the path 2 bytes at a time. */