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
This commit is contained in:
Dag-Erling Smørgrav 2023-02-03 16:37:24 +01:00
parent 87e728340b
commit cb96a0ef00
2 changed files with 3 additions and 5 deletions

View File

@ -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) {
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR:

View File

@ -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 @@ copy_file(const FTSENT *entp, int dne)
int
copy_link(const FTSENT *p, int exists)
{
int len;
ssize_t len;
char llink[PATH_MAX];
if (exists && nflag) {