summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorrobert <robert@FreeBSD.org>2002-05-27 11:01:30 +0000
committerrobert <robert@FreeBSD.org>2002-05-27 11:01:30 +0000
commit1a1155b2046a833f4df478b8d96ec4b2fcddaf8c (patch)
treeb3523d65d7c35e7e86d6df16688cfdbfad068e5d /lib/libc/stdio
parent447608687bc0a0a8651744b1697a4d84854ac532 (diff)
downloadFreeBSD-src-1a1155b2046a833f4df478b8d96ec4b2fcddaf8c.zip
FreeBSD-src-1a1155b2046a833f4df478b8d96ec4b2fcddaf8c.tar.gz
- Move the loop conditional into the "for" header.
- Remove redundant "? :" construct. style(9): - Place a space after return statements. - Compare pointers to NULL. - Do not use ! to compare a character to nul.
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/mktemp.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index 49ba17d..186d8b0 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -79,14 +79,14 @@ char *
mkdtemp(path)
char *path;
{
- return(_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
+ return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
}
char *
_mktemp(path)
char *path;
{
- return(_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
+ return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
}
__warn_references(mktemp,
@@ -96,7 +96,7 @@ char *
mktemp(path)
char *path;
{
- return(_mktemp(path));
+ return (_mktemp(path));
}
static int
@@ -112,12 +112,12 @@ _gettemp(path, doopen, domkdir, slen)
int rval;
uint32_t rand;
- if (doopen && domkdir) {
+ if (doopen != NULL && domkdir) {
errno = EINVAL;
- return(0);
+ return (0);
}
- for (trv = path; *trv; ++trv)
+ for (trv = path; *trv != '\0'; ++trv)
;
trv -= slen;
suffp = trv;
@@ -137,19 +137,17 @@ _gettemp(path, doopen, domkdir, slen)
/*
* check the target directory.
*/
- if (doopen || domkdir) {
- for (;; --trv) {
- if (trv <= path)
- break;
+ if (doopen != NULL || domkdir) {
+ for (; trv > path; --trv) {
if (*trv == '/') {
*trv = '\0';
rval = stat(path, &sbuf);
*trv = '/';
if (rval != 0)
- return(0);
+ return (0);
if (!S_ISDIR(sbuf.st_mode)) {
errno = ENOTDIR;
- return(0);
+ return (0);
}
break;
}
@@ -160,23 +158,23 @@ _gettemp(path, doopen, domkdir, slen)
if (doopen) {
if ((*doopen =
_open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
- return(1);
+ return (1);
if (errno != EEXIST)
- return(0);
+ return (0);
} else if (domkdir) {
if (mkdir(path, 0700) == 0)
- return(1);
+ return (1);
if (errno != EEXIST)
- return(0);
+ return (0);
} else if (lstat(path, &sbuf))
- return(errno == ENOENT ? 1 : 0);
+ return (errno == ENOENT);
/* If we have a collision, cycle through the space of filenames */
for (trv = start;;) {
if (*trv == '\0' || trv == suffp)
- return(0);
+ return (0);
pad = strchr(padchar, *trv);
- if (pad == NULL || !*++pad)
+ if (pad == NULL || *++pad != '\0')
*trv++ = padchar[0];
else {
*trv++ = *pad;
OpenPOWER on IntegriCloud