summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-09-21 04:38:56 +0000
committerguenther <guenther@openbsd.org>2016-09-21 04:38:56 +0000
commit3240e6a8f93e9dcb3b95e7fafb9e2b27f13c7c9d (patch)
tree7368a30a463d94567dfeaa9177978c7039ebf249 /lib/libc/stdio
parentsync (diff)
downloadwireguard-openbsd-3240e6a8f93e9dcb3b95e7fafb9e2b27f13c7c9d.tar.xz
wireguard-openbsd-3240e6a8f93e9dcb3b95e7fafb9e2b27f13c7c9d.zip
Delete casts to off_t and size_t that are implied by assignments
or prototypes. Ditto for some of the char* and void* casts too. verified no change to instructions on ILP32 (i386) and LP64 (amd64) ok natano@ abluhm@ deraadt@ millert@
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/fgetln.c12
-rw-r--r--lib/libc/stdio/fgets.c8
-rw-r--r--lib/libc/stdio/fopen.c4
-rw-r--r--lib/libc/stdio/fread.c6
-rw-r--r--lib/libc/stdio/freopen.c4
-rw-r--r--lib/libc/stdio/fsetpos.c4
-rw-r--r--lib/libc/stdio/fvwrite.c6
-rw-r--r--lib/libc/stdio/getdelim.c4
-rw-r--r--lib/libc/stdio/getw.c4
-rw-r--r--lib/libc/stdio/setbuffer.c4
-rw-r--r--lib/libc/stdio/setvbuf.c4
-rw-r--r--lib/libc/stdio/stdio.c11
-rw-r--r--lib/libc/stdio/ungetc.c6
-rw-r--r--lib/libc/stdio/vfscanf.c4
14 files changed, 39 insertions, 42 deletions
diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c
index a5ea1b3207e..bdb0c2a5b37 100644
--- a/lib/libc/stdio/fgetln.c
+++ b/lib/libc/stdio/fgetln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fgetln.c,v 1.15 2016/08/25 19:21:33 schwarze Exp $ */
+/* $OpenBSD: fgetln.c,v 1.16 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -76,7 +76,7 @@ fgetln(FILE *fp, size_t *lenp)
goto error;
/* look for a newline in the input */
- if ((p = memchr((void *)fp->_p, '\n', fp->_r)) != NULL) {
+ if ((p = memchr(fp->_p, '\n', fp->_r)) != NULL) {
/*
* Found one. Flag buffer as modified to keep fseek from
* `optimising' a backward seek, in case the user stomps on
@@ -112,15 +112,14 @@ fgetln(FILE *fp, size_t *lenp)
*/
if (__slbexpand(fp, len + OPTIMISTIC))
goto error;
- (void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
- len - off);
+ (void)memcpy(fp->_lb._base + off, fp->_p, len - off);
off = len;
if (__srefill(fp)) {
if (fp->_flags & __SEOF)
break;
goto error;
}
- if ((p = memchr((void *)fp->_p, '\n', fp->_r)) == NULL)
+ if ((p = memchr(fp->_p, '\n', fp->_r)) == NULL)
continue;
/* got it: finish up the line (like code above) */
@@ -129,8 +128,7 @@ fgetln(FILE *fp, size_t *lenp)
len += diff;
if (__slbexpand(fp, len))
goto error;
- (void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
- diff);
+ (void)memcpy(fp->_lb._base + off, fp->_p, diff);
fp->_r -= diff;
fp->_p = p;
break;
diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c
index 5966c0bf903..e0eec107d3a 100644
--- a/lib/libc/stdio/fgets.c
+++ b/lib/libc/stdio/fgets.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fgets.c,v 1.15 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: fgets.c,v 1.16 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -83,19 +83,19 @@ fgets(char *buf, int n, FILE *fp)
*/
if (len > n)
len = n;
- t = memchr((void *)p, '\n', len);
+ t = memchr(p, '\n', len);
if (t != NULL) {
len = ++t - p;
fp->_r -= len;
fp->_p = t;
- (void)memcpy((void *)s, (void *)p, len);
+ (void)memcpy(s, p, len);
s[len] = '\0';
FUNLOCKFILE(fp);
return (buf);
}
fp->_r -= len;
fp->_p += len;
- (void)memcpy((void *)s, (void *)p, len);
+ (void)memcpy(s, p, len);
s += len;
n -= len;
}
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 6936321d643..5932a552158 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fopen.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: fopen.c,v 1.9 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -81,7 +81,7 @@ fopen(const char *file, const char *mode)
* fseek and ftell.)
*/
if (oflags & O_APPEND)
- (void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
+ (void) __sseek(fp, 0, SEEK_END);
return (fp);
}
DEF_STRONG(fopen);
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index 35c73322a58..33c558708d2 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fread.c,v 1.14 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: fread.c,v 1.15 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -84,7 +84,7 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
}
while (resid > (r = fp->_r)) {
- (void)memcpy((void *)p, (void *)fp->_p, (size_t)r);
+ (void)memcpy(p, fp->_p, r);
fp->_p += r;
/* fp->_r = 0 ... done in __srefill */
p += r;
@@ -95,7 +95,7 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
return ((total - resid) / size);
}
}
- (void)memcpy((void *)p, (void *)fp->_p, resid);
+ (void)memcpy(p, fp->_p, resid);
fp->_r -= resid;
fp->_p += resid;
FUNLOCKFILE(fp);
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index 442370d870b..3d4f8421301 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: freopen.c,v 1.15 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: freopen.c,v 1.16 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -165,7 +165,7 @@ freopen(const char *file, const char *mode, FILE *fp)
* fseek and ftell.)
*/
if (oflags & O_APPEND)
- (void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
+ (void) __sseek(fp, 0, SEEK_END);
FUNLOCKFILE(fp);
return (fp);
}
diff --git a/lib/libc/stdio/fsetpos.c b/lib/libc/stdio/fsetpos.c
index d389f5efa7f..9af0d0749e9 100644
--- a/lib/libc/stdio/fsetpos.c
+++ b/lib/libc/stdio/fsetpos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsetpos.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: fsetpos.c,v 1.8 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,6 +39,6 @@
int
fsetpos(FILE *iop, const fpos_t *pos)
{
- return (fseeko(iop, (off_t)*pos, SEEK_SET));
+ return (fseeko(iop, *pos, SEEK_SET));
}
DEF_STRONG(fsetpos);
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 1088991fd59..7517b5f00da 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fvwrite.c,v 1.17 2009/11/09 00:18:27 kurt Exp $ */
+/* $OpenBSD: fvwrite.c,v 1.18 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -63,7 +63,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
}
#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
+#define COPY(n) (void)memcpy(fp->_p, p, n)
iov = uio->uio_iov;
p = iov->iov_base;
@@ -164,7 +164,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
do {
GETIOV(nlknown = 0);
if (!nlknown) {
- nl = memchr((void *)p, '\n', len);
+ nl = memchr(p, '\n', len);
nldist = nl ? nl + 1 - p : len + 1;
nlknown = 1;
}
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c
index 58ff0a1be12..0e0e338328c 100644
--- a/lib/libc/stdio/getdelim.c
+++ b/lib/libc/stdio/getdelim.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getdelim.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: getdelim.c,v 1.5 2016/09/21 04:38:56 guenther Exp $ */
/* $NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $ */
/*
@@ -73,7 +73,7 @@ getdelim(char **__restrict buf, size_t *__restrict buflen,
}
/* Scan through looking for the separator */
- p = memchr(fp->_p, sep, (size_t)fp->_r);
+ p = memchr(fp->_p, sep, fp->_r);
if (p == NULL)
len = fp->_r;
else
diff --git a/lib/libc/stdio/getw.c b/lib/libc/stdio/getw.c
index a6688be7c74..37adb6d0ff4 100644
--- a/lib/libc/stdio/getw.c
+++ b/lib/libc/stdio/getw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getw.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: getw.c,v 1.7 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -38,6 +38,6 @@ getw(FILE *fp)
{
int x;
- return (fread((void *)&x, sizeof(x), 1, fp) == 1 ? x : EOF);
+ return (fread(&x, sizeof(x), 1, fp) == 1 ? x : EOF);
}
DEF_WEAK(getw);
diff --git a/lib/libc/stdio/setbuffer.c b/lib/libc/stdio/setbuffer.c
index b67d7659494..d5695313909 100644
--- a/lib/libc/stdio/setbuffer.c
+++ b/lib/libc/stdio/setbuffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setbuffer.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: setbuffer.c,v 1.7 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -48,6 +48,6 @@ int
setlinebuf(FILE *fp)
{
- return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0));
+ return (setvbuf(fp, NULL, _IOLBF, 0));
}
DEF_WEAK(setlinebuf);
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c
index 02879a771a6..9a08d133f5f 100644
--- a/lib/libc/stdio/setvbuf.c
+++ b/lib/libc/stdio/setvbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setvbuf.c,v 1.13 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: setvbuf.c,v 1.14 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -70,7 +70,7 @@ setvbuf(FILE *fp, char *buf, int mode, size_t size)
fp->_r = fp->_lbfsize = 0;
flags = fp->_flags;
if (flags & __SMBF)
- free((void *)fp->_bf._base);
+ free(fp->_bf._base);
flags &= ~(__SLBF | __SNBF | __SMBF | __SOPT | __SNPT | __SEOF);
/* If setting unbuffered mode, skip all the hard work. */
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index a4a27b53b64..fe28f00918c 100644
--- a/lib/libc/stdio/stdio.c
+++ b/lib/libc/stdio/stdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdio.c,v 1.9 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: stdio.c,v 1.10 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,9 +31,8 @@
* SUCH DAMAGE.
*/
-#include <fcntl.h>
-#include <unistd.h>
#include <stdio.h>
+#include <unistd.h>
#include "local.h"
/*
@@ -61,7 +60,7 @@ __swrite(void *cookie, const char *buf, int n)
FILE *fp = cookie;
if (fp->_flags & __SAPP)
- (void) lseek(fp->_file, (off_t)0, SEEK_END);
+ (void) lseek(fp->_file, 0, SEEK_END);
fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */
return (write(fp->_file, buf, n));
}
@@ -72,8 +71,8 @@ __sseek(void *cookie, fpos_t offset, int whence)
FILE *fp = cookie;
off_t ret;
- ret = lseek(fp->_file, (off_t)offset, whence);
- if (ret == (off_t)-1)
+ ret = lseek(fp->_file, offset, whence);
+ if (ret == -1)
fp->_flags &= ~__SOFF;
else {
fp->_flags |= __SOFF;
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index cb49c9bd195..4cd638b2e17 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ungetc.c,v 1.14 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: ungetc.c,v 1.15 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -53,7 +53,7 @@ __submore(FILE *fp)
/*
* Get a new buffer (rather than expanding the old one).
*/
- if ((p = malloc((size_t)BUFSIZ)) == NULL)
+ if ((p = malloc(BUFSIZ)) == NULL)
return (EOF);
_UB(fp)._base = p;
_UB(fp)._size = BUFSIZ;
@@ -68,7 +68,7 @@ __submore(FILE *fp)
if (p == NULL)
return (EOF);
/* no overlap (hence can use memcpy) because we doubled the size */
- (void)memcpy((void *)(p + i), (void *)p, (size_t)i);
+ (void)memcpy(p + i, p, i);
fp->_p = p + i;
_UB(fp)._base = p;
_UB(fp)._size = i * 2;
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 83a3bfb6c05..ec2a2cfc23d 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfscanf.c,v 1.32 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: vfscanf.c,v 1.33 2016/09/21 04:38:56 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -401,7 +401,7 @@ literal:
}
nread += sum;
} else {
- size_t r = fread((void *)va_arg(ap, char *), 1,
+ size_t r = fread(va_arg(ap, char *), 1,
width, fp);
if (r == 0)