Date: Sun, 24 Jan 2021 11:06:50 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 97a463120bf9 - main - libc: skip spurious stat in _gettemp Message-ID: <202101241106.10OB6oFI040765@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=97a463120bf99819fcb21a781e410fb43dde2a43 commit 97a463120bf99819fcb21a781e410fb43dde2a43 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-01-24 04:15:13 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-01-24 11:06:36 +0000 libc: skip spurious stat in _gettemp It was only done to catch ENOTDIR, but the kernel already returns the error where appropriate. --- lib/libc/stdio/mktemp.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index f08d92cc3ec7..f64eda748d0b 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -121,7 +121,6 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags) char *start, *trv, *suffp, *carryp; char *pad; struct stat sbuf; - int rval; uint32_t rand; char carrybuf[MAXPATHLEN]; @@ -156,26 +155,6 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags) /* save first combination of random characters */ memcpy(carrybuf, start, suffp - start); - /* - * check the target directory. - */ - if (doopen != NULL || domkdir) { - for (; trv > path; --trv) { - if (*trv == '/') { - *trv = '\0'; - rval = fstatat(dfd, path, &sbuf, 0); - *trv = '/'; - if (rval != 0) - return (0); - if (!S_ISDIR(sbuf.st_mode)) { - errno = ENOTDIR; - return (0); - } - break; - } - } - } - oflags |= O_CREAT | O_EXCL | O_RDWR; for (;;) { if (doopen) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101241106.10OB6oFI040765>