am f2102f54: Merge "Quiten warnings in fts.c."
* commit 'f2102f54a0006c56033ab0ba62d48dc4b4e8b91a': Quiten warnings in fts.c.
This commit is contained in:
commit
d103c98be8
@ -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
|
* Copyright (c) 1990, 1993, 1994
|
||||||
@ -36,6 +36,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -97,7 +98,7 @@ fts_open(char * const *argv, int options,
|
|||||||
* Start out with 1K of path space, and enough, in any case,
|
* Start out with 1K of path space, and enough, in any case,
|
||||||
* to hold the user's paths.
|
* 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;
|
goto mem1;
|
||||||
|
|
||||||
/* Allocate/initialize root's parent. */
|
/* Allocate/initialize root's parent. */
|
||||||
@ -447,7 +448,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
|||||||
*/
|
*/
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
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 &&
|
if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
|
||||||
instr != FTS_NOINSTR && instr != FTS_SKIP) {
|
instr != FTS_NOINSTR && instr != FTS_SKIP) {
|
||||||
@ -637,7 +638,7 @@ fts_build(FTS *sp, int type)
|
|||||||
maxlen = sp->fts_pathlen - len;
|
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.
|
* around to FTS_ROOTLEVEL and FTS_ROOTPARENTLEVEL.
|
||||||
*/
|
*/
|
||||||
level = cur->fts_level;
|
level = cur->fts_level;
|
||||||
@ -908,10 +909,9 @@ fts_alloc(FTS *sp, char *name, size_t namelen)
|
|||||||
len = sizeof(FTSENT) + namelen;
|
len = sizeof(FTSENT) + namelen;
|
||||||
if (!ISSET(FTS_NOSTAT))
|
if (!ISSET(FTS_NOSTAT))
|
||||||
len += sizeof(struct stat) + ALIGNBYTES;
|
len += sizeof(struct stat) + ALIGNBYTES;
|
||||||
if ((p = malloc(len)) == NULL)
|
if ((p = calloc(1, len)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
memset(p, 0, len);
|
|
||||||
p->fts_path = sp->fts_path;
|
p->fts_path = sp->fts_path;
|
||||||
p->fts_namelen = namelen;
|
p->fts_namelen = namelen;
|
||||||
p->fts_instr = FTS_NOINSTR;
|
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.
|
* 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)
|
* 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.
|
* plus 256 bytes so don't realloc the path 2 bytes at a time.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user