Re: git: cb96a0ef0040 - main - cp: Minor code cleanup.
Date: Fri, 03 Feb 2023 15:58:02 UTC
> The branch main has been updated by des: > > URL: https://cgit.FreeBSD.org/src/commit/?id=cb96a0ef0040fa7968245ab203ab70a7ed2d275d > > commit cb96a0ef0040fa7968245ab203ab70a7ed2d275d > Author: Dag-Erling Sm?rgrav <des@FreeBSD.org> > AuthorDate: 2023-02-03 15:37:24 +0000 > Commit: Dag-Erling Sm?rgrav <des@FreeBSD.org> > CommitDate: 2023-02-03 15:37:37 +0000 > > cp: Minor code cleanup. > > * Fix includes in utils.c, cf. style(9). > * Fix type mismatch: readlink(2) returns ssize_t, not int. > * It is not necessary to set errno to 0 as fts_read(3) already does it. > > MFC after: 1 week > Sponsored by: Klara, Inc. > Reviewed by: allanjude > Differential Revision: https://reviews.freebsd.org/D38369 > --- > bin/cp/cp.c | 3 +-- > bin/cp/utils.c | 5 ++--- > 2 files changed, 3 insertions(+), 5 deletions(-) > > diff --git a/bin/cp/cp.c b/bin/cp/cp.c > index dbae4b535843..e38cd97f4369 100644 > --- a/bin/cp/cp.c > +++ b/bin/cp/cp.c > @@ -311,8 +311,7 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat) > recurse_path = NULL; > if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL) > err(1, "fts_open"); > - for (badcp = rval = 0; errno = 0, (curr = fts_read(ftsp)) != NULL; > - badcp = 0) { > + for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) { Wouldnt it now be possible for code in the fts_read path to reference errno unintialized? > switch (curr->fts_info) { > case FTS_NS: > case FTS_DNR: > diff --git a/bin/cp/utils.c b/bin/cp/utils.c > index a3a498714f43..8c1c350ff6f1 100644 > --- a/bin/cp/utils.c > +++ b/bin/cp/utils.c > @@ -37,9 +37,8 @@ static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94"; > #include <sys/cdefs.h> > __FBSDID("$FreeBSD$"); > > -#include <sys/types.h> > -#include <sys/acl.h> > #include <sys/param.h> > +#include <sys/acl.h> > #include <sys/stat.h> > > #include <err.h> > @@ -241,7 +240,7 @@ done: > int > copy_link(const FTSENT *p, int exists) > { > - int len; > + ssize_t len; > char llink[PATH_MAX]; > > if (exists && nflag) { > -- Rod Grimes rgrimes@freebsd.org