diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-09-21 04:38:58 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-09-21 04:38:58 +0000 |
commit | 8358f9eb58e7f7d84095aa5aaf19cbcd1a2b7e45 (patch) | |
tree | 0108f3739bcd8e73c3f9cab4c5533af4f6bdc978 /lib | |
parent | e2c934e5fade3e10a8f429303bac3a8d9ea99b45 (diff) |
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')
35 files changed, 106 insertions, 114 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 5b1c2980362..2b1c2232f4e 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.28 2015/12/28 22:08:18 mmcc Exp $ */ +/* $OpenBSD: hash.c,v 1.29 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -477,7 +477,7 @@ flush_meta(HTAB *hashp) whdrp = &whdr; swap_header_copy(&hashp->hdr, whdrp); #endif - if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), (off_t)0)) == -1) + if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), 0)) == -1) return (-1); else if (wsize != sizeof(HASHHDR)) { diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c index 4afc2b153eb..567c34c96db 100644 --- a/lib/libc/db/recno/rec_close.c +++ b/lib/libc/db/recno/rec_close.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rec_close.c,v 1.12 2015/07/16 04:27:33 tedu Exp $ */ +/* $OpenBSD: rec_close.c,v 1.13 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -124,7 +124,7 @@ __rec_sync(const DB *dbp, u_int flags) return (RET_ERROR); /* Rewind the file descriptor. */ - if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0) + if (lseek(t->bt_rfd, 0, SEEK_SET) != 0) return (RET_ERROR); /* Save the cursor. */ @@ -164,7 +164,7 @@ __rec_sync(const DB *dbp, u_int flags) if (status == RET_ERROR) return (RET_ERROR); - if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1) + if ((off = lseek(t->bt_rfd, 0, SEEK_CUR)) == -1) return (RET_ERROR); if (ftruncate(t->bt_rfd, off)) return (RET_ERROR); diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index b8e688f9cef..6683c9fd03e 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rec_open.c,v 1.12 2015/07/16 04:27:33 tedu Exp $ */ +/* $OpenBSD: rec_open.c,v 1.13 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -112,7 +112,7 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo, * and check the errno values. */ errno = 0; - if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { + if (lseek(rfd, 0, SEEK_CUR) == -1 && errno == ESPIPE) { switch (flags & O_ACCMODE) { case O_RDONLY: F_SET(t, R_RDONLY); diff --git a/lib/libc/gdtoa/misc.c b/lib/libc/gdtoa/misc.c index 64e19701116..fef51a954a1 100644 --- a/lib/libc/gdtoa/misc.c +++ b/lib/libc/gdtoa/misc.c @@ -102,9 +102,9 @@ Bfree if (v) { if (v->k > Kmax) #ifdef FREE - FREE((void*)v); + FREE(v); #else - free((void*)v); + free(v); #endif else { ACQUIRE_DTOA_LOCK(0); diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 9a9b2a5a5cd..bcf9d1661f1 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.55 2016/06/28 17:21:48 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -654,7 +654,7 @@ fts_build(FTS *sp, int type) if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) continue; - if (!(p = fts_alloc(sp, dp->d_name, (size_t)dp->d_namlen))) + if (!(p = fts_alloc(sp, dp->d_name, dp->d_namlen))) goto mem1; if (dp->d_namlen >= maxlen) { /* include space for NUL */ oldaddr = sp->fts_path; @@ -894,7 +894,7 @@ fts_sort(FTS *sp, FTSENT *head, int nitems) } for (ap = sp->fts_array, p = head; p; p = p->fts_link) *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar); + qsort(sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar); for (head = *(ap = sp->fts_array); --nitems; ++ap) ap[0]->fts_link = ap[1]; ap[0]->fts_link = NULL; diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index 5b9f812653b..9a8a49ed294 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getcap.c,v 1.33 2015/09/14 16:09:13 tedu Exp $ */ +/* $OpenBSD: getcap.c,v 1.34 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -537,8 +537,7 @@ tc_exp: { if (r_end > rp) { char *nrecord; - if ((nrecord = - realloc(record, (size_t)(rp - record))) == NULL) { + if ((nrecord = realloc(record, rp - record)) == NULL) { free(record); errno = ENOMEM; return (-2); @@ -772,7 +771,7 @@ cgetnext(char **cap, char **db_array) */ if (*record != '\0' && *record != '#') { /* Rewind to end of record */ - fseeko(pfp, (off_t)(bp - b_end), SEEK_CUR); + fseeko(pfp, bp - b_end, SEEK_CUR); toprec = record; topreclen = rp - record; break; @@ -924,7 +923,7 @@ cgetstr(char *buf, const char *cap, char **str) if (m_room != 0) { char *nmem; - if ((nmem = realloc(mem, (size_t)(mp - mem))) == NULL) { + if ((nmem = realloc(mem, mp - mem)) == NULL) { free(mem); return (-2); } diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 7506154d26b..fa966ac8b24 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.66 2015/12/29 22:31:21 mmcc Exp $ */ +/* $OpenBSD: nlist.c,v 1.67 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -101,7 +101,7 @@ __fdnlist(int fd, struct nlist *list) size_t left, len; /* Make sure obj is OK */ - if (pread(fd, &ehdr, sizeof(Elf_Ehdr), (off_t)0) != sizeof(Elf_Ehdr) || + if (pread(fd, &ehdr, sizeof(Elf_Ehdr), 0) != sizeof(Elf_Ehdr) || !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) return (-1); @@ -116,15 +116,14 @@ __fdnlist(int fd, struct nlist *list) } /* mmap section header table */ - shdr = (Elf_Shdr *)mmap(NULL, (size_t)shdr_size, PROT_READ, - MAP_SHARED|MAP_FILE, fd, (off_t) ehdr.e_shoff); + shdr = mmap(NULL, shdr_size, PROT_READ, MAP_SHARED|MAP_FILE, fd, + ehdr.e_shoff); if (shdr == MAP_FAILED) { usemalloc = 1; if ((shdr = malloc(shdr_size)) == NULL) return (-1); - if (pread(fd, shdr, shdr_size, (off_t)ehdr.e_shoff) != - shdr_size) { + if (pread(fd, shdr, shdr_size, ehdr.e_shoff) != shdr_size) { free(shdr); return (-1); } @@ -194,21 +193,20 @@ __fdnlist(int fd, struct nlist *list) if (usemalloc) { if ((strtab = malloc(symstrsize)) == NULL) return (-1); - if (pread(fd, strtab, symstrsize, (off_t)symstroff) != - symstrsize) { + if (pread(fd, strtab, symstrsize, symstroff) != symstrsize) { free(strtab); return (-1); } } else { - strtab = mmap(NULL, (size_t)symstrsize, PROT_READ, - MAP_SHARED|MAP_FILE, fd, (off_t) symstroff); + strtab = mmap(NULL, symstrsize, PROT_READ, MAP_SHARED|MAP_FILE, + fd, symstroff); if (strtab == MAP_FAILED) return (-1); } while (symsize >= sizeof(Elf_Sym)) { cc = MINIMUM(symsize, sizeof(sbuf)); - if (pread(fd, sbuf, cc, (off_t)symoff) != cc) + if (pread(fd, sbuf, cc, symoff) != cc) break; symsize -= cc; symoff += cc; diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 38662ae4457..71d30da9386 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opendir.c,v 1.29 2015/09/12 13:34:22 guenther Exp $ */ +/* $OpenBSD: opendir.c,v 1.30 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -107,7 +107,7 @@ __fdopendir(int fd) pageoffset = getpagesize() - 1; dirp->dd_len = ((int)sb.st_blksize * 4 + pageoffset) & ~pageoffset; - dirp->dd_buf = malloc((size_t)dirp->dd_len); + dirp->dd_buf = malloc(dirp->dd_len); if (dirp->dd_buf == NULL) { free(dirp); return (NULL); diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index f505eb79d12..cbfd663e839 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gmon.c,v 1.29 2016/05/07 19:30:52 guenther Exp $ */ +/* $OpenBSD: gmon.c,v 1.30 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1983, 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -77,19 +77,19 @@ monstartup(u_long lowpc, u_long highpc) p->tossize = p->tolimit * sizeof(struct tostruct); addr = mmap(NULL, p->kcountsize, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, -1, (off_t)0); + MAP_ANON|MAP_PRIVATE, -1, 0); if (addr == MAP_FAILED) goto mapfailed; p->kcount = addr; addr = mmap(NULL, p->fromssize, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, -1, (off_t)0); + MAP_ANON|MAP_PRIVATE, -1, 0); if (addr == MAP_FAILED) goto mapfailed; p->froms = addr; addr = mmap(NULL, p->tossize, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, -1, (off_t)0); + MAP_ANON|MAP_PRIVATE, -1, 0); if (addr == MAP_FAILED) goto mapfailed; p->tos = addr; diff --git a/lib/libc/hash/helper.c b/lib/libc/hash/helper.c index 38008aedf22..6b4e77dfb98 100644 --- a/lib/libc/hash/helper.c +++ b/lib/libc/hash/helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: helper.c,v 1.15 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: helper.c,v 1.16 2016/09/21 04:38:57 guenther Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org> @@ -82,7 +82,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len) } while ((nr = read(fd, buffer, MINIMUM(sizeof(buffer), len))) > 0) { - HASHUpdate(&ctx, buffer, (size_t)nr); + HASHUpdate(&ctx, buffer, nr); if (len > 0 && (len -= nr) == 0) break; } @@ -97,7 +97,7 @@ DEF_WEAK(HASHFileChunk); char * HASHFile(const char *filename, char *buf) { - return (HASHFileChunk(filename, buf, (off_t)0, (off_t)0)); + return (HASHFileChunk(filename, buf, 0, 0)); } DEF_WEAK(HASHFile); diff --git a/lib/libc/net/ethers.c b/lib/libc/net/ethers.c index a7e0796c72f..de68c092f8c 100644 --- a/lib/libc/net/ethers.c +++ b/lib/libc/net/ethers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ethers.c,v 1.24 2015/09/14 11:01:47 guenther Exp $ */ +/* $OpenBSD: ethers.c,v 1.25 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> @@ -144,7 +144,7 @@ ether_ntohost(char *hostname, struct ether_addr *e) } #endif if (ether_line(buf, &try, hostname) == 0 && - memcmp((void *)&try, (void *)e, sizeof(try)) == 0) { + memcmp(&try, e, sizeof(try)) == 0) { (void)fclose(f); return (0); } diff --git a/lib/libc/net/freeaddrinfo.c b/lib/libc/net/freeaddrinfo.c index 2ac84a31f3b..154f70cd75e 100644 --- a/lib/libc/net/freeaddrinfo.c +++ b/lib/libc/net/freeaddrinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freeaddrinfo.c,v 1.8 2015/12/28 22:08:18 mmcc Exp $ */ +/* $OpenBSD: freeaddrinfo.c,v 1.9 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, Craig Metz, All rights reserved. @@ -44,7 +44,7 @@ freeaddrinfo(struct addrinfo *ai) p = ai; ai = ai->ai_next; free(p->ai_canonname); - free((void *)p); + free(p); } while (ai); } DEF_WEAK(freeaddrinfo); diff --git a/lib/libc/net/inet_ntop.c b/lib/libc/net/inet_ntop.c index f44dd080221..2bb11c2ab29 100644 --- a/lib/libc/net/inet_ntop.c +++ b/lib/libc/net/inet_ntop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet_ntop.c,v 1.12 2015/09/13 21:36:08 guenther Exp $ */ +/* $OpenBSD: inet_ntop.c,v 1.13 2016/09/21 04:38:56 guenther Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. * @@ -46,9 +46,9 @@ inet_ntop(int af, const void *src, char *dst, socklen_t size) { switch (af) { case AF_INET: - return (inet_ntop4(src, dst, (size_t)size)); + return (inet_ntop4(src, dst, size)); case AF_INET6: - return (inet_ntop6(src, dst, (size_t)size)); + return (inet_ntop6(src, dst, size)); default: errno = EAFNOSUPPORT; return (NULL); @@ -167,7 +167,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, (size_t)(ep - tp))) + if (!inet_ntop4(src+12, tp, ep - tp)) return (NULL); tp += strlen(tp); break; diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c index 1a29e87de14..934a55155a8 100644 --- a/lib/libc/net/rthdr.c +++ b/lib/libc/net/rthdr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthdr.c,v 1.11 2015/09/14 11:01:47 guenther Exp $ */ +/* $OpenBSD: rthdr.c,v 1.12 2016/09/21 04:38:56 guenther Exp $ */ /* $KAME: rthdr.c,v 1.22 2006/02/09 08:18:58 keiichi Exp $ */ /* @@ -120,8 +120,7 @@ inet6_rth_reverse(const void *in, void *out) segments = rth0_in->ip6r0_len / 2; /* we can't use memcpy here, since in and out may overlap */ - memmove((void *)rth0_out, (void *)rth0_in, - ((rth0_in->ip6r0_len) + 1) << 3); + memmove(rth0_out, rth0_in, ((rth0_in->ip6r0_len) + 1) << 3); rth0_out->ip6r0_segleft = segments; /* reverse the addresses */ diff --git a/lib/libc/nls/catopen.c b/lib/libc/nls/catopen.c index 1ca1a95170c..af7869bdc7c 100644 --- a/lib/libc/nls/catopen.c +++ b/lib/libc/nls/catopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: catopen.c,v 1.19 2015/11/05 23:38:07 bluhm Exp $ */ +/* $OpenBSD: catopen.c,v 1.20 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. @@ -184,7 +184,7 @@ load_msgcat(const char *path) return (nl_catd) -1; } - data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0); + data = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); close (fd); if (data == MAP_FAILED) @@ -206,7 +206,7 @@ load_msgcat(const char *path) invalid: free(catd); - munmap(data, (size_t) st.st_size); + munmap(data, st.st_size); errno = EINVAL; return (nl_catd) -1; } diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 261956bec96..2fdf63a0ee1 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.23 2016/05/26 05:46:44 martijn Exp $ */ +/* $OpenBSD: engine.c,v 1.24 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -156,7 +156,7 @@ matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], if (g->must != NULL) { for (dp = start; dp < stop; dp++) if (*dp == g->must[0] && stop - dp >= g->mlen && - memcmp(dp, g->must, (size_t)g->mlen) == 0) + memcmp(dp, g->must, g->mlen) == 0) break; if (dp == stop) /* we didn't find g->must */ return(REG_NOMATCH); diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index e455a571c68..d848a492614 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regcomp.c,v 1.28 2015/12/28 22:08:18 mmcc Exp $ */ +/* $OpenBSD: regcomp.c,v 1.29 2016/09/21 04:38:56 guenther Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 @@ -1294,8 +1294,7 @@ dupl(struct parse *p, return(ret); if (!enlarge(p, p->ssize + len)) /* this many unexpected additions */ return(ret); - (void) memcpy((char *)(p->strip + p->slen), - (char *)(p->strip + start), (size_t)len*sizeof(sop)); + (void) memcpy(p->strip + p->slen, p->strip + start, len * sizeof(sop)); p->slen += len; return(ret); } diff --git a/lib/libc/rpc/xdr_rec.c b/lib/libc/rpc/xdr_rec.c index 7a94a4d003b..8feeb0d3468 100644 --- a/lib/libc/rpc/xdr_rec.c +++ b/lib/libc/rpc/xdr_rec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr_rec.c,v 1.21 2015/10/04 06:37:21 guenther Exp $ */ +/* $OpenBSD: xdr_rec.c,v 1.22 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -321,8 +321,8 @@ xdrrec_getpos(XDR *xdrs) RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; off_t pos; - pos = lseek((int)(long)rstrm->tcp_handle, (off_t)0, SEEK_CUR); - if (pos != (off_t)-1) + pos = lseek((int)(long)rstrm->tcp_handle, 0, SEEK_CUR); + if (pos != -1) switch (xdrs->x_op) { case XDR_ENCODE: @@ -646,7 +646,7 @@ get_input_bytes(RECSTREAM *rstrm, caddr_t addr, int len) if (rstrm->nonblock) { if (len > (int)(rstrm->in_boundry - rstrm->in_finger)) return FALSE; - memcpy(addr, rstrm->in_finger, (size_t)len); + memcpy(addr, rstrm->in_finger, len); rstrm->in_finger += len; return (TRUE); } @@ -730,7 +730,7 @@ realloc_stream(RECSTREAM *rstrm, int size) char *buf; if (size > rstrm->recvsize) { - buf = realloc(rstrm->in_base, (size_t)size); + buf = realloc(rstrm->in_base, size); if (buf == NULL) return (FALSE); diff = buf - rstrm->in_base; 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) diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 0296985e5b5..20807a25b46 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.196 2016/09/18 13:46:28 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.197 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -83,14 +83,14 @@ #define SOME_JUNK 0xd0 /* as in "Duh" :-) */ #define SOME_FREEJUNK 0xdf -#define MMAP(sz) mmap(NULL, (size_t)(sz), PROT_READ | PROT_WRITE, \ - MAP_ANON | MAP_PRIVATE, -1, (off_t) 0) +#define MMAP(sz) mmap(NULL, (sz), PROT_READ | PROT_WRITE, \ + MAP_ANON | MAP_PRIVATE, -1, 0) -#define MMAPA(a,sz) mmap((a), (size_t)(sz), PROT_READ | PROT_WRITE, \ - MAP_ANON | MAP_PRIVATE, -1, (off_t) 0) +#define MMAPA(a,sz) mmap((a), (sz), PROT_READ | PROT_WRITE, \ + MAP_ANON | MAP_PRIVATE, -1, 0) -#define MQUERY(a, sz) mquery((a), (size_t)(sz), PROT_READ | PROT_WRITE, \ - MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, (off_t)0) +#define MQUERY(a, sz) mquery((a), (sz), PROT_READ | PROT_WRITE, \ + MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) struct region_info { void *p; /* page; low bits used to mark chunks */ diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c index 60c2cd46a65..15c550ba30b 100644 --- a/lib/libc/stdlib/setenv.c +++ b/lib/libc/stdlib/setenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setenv.c,v 1.18 2016/04/25 21:36:04 millert Exp $ */ +/* $OpenBSD: setenv.c,v 1.19 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. @@ -141,7 +141,7 @@ setenv(const char *name, const char *value, int rewrite) environ[cnt + 1] = NULL; } if (!(environ[offset] = /* name + `=' + value */ - malloc((size_t)((int)(np - name) + l_value + 2)))) + malloc((int)(np - name) + l_value + 2))) return (-1); for (C = environ[offset]; (*C = *name++) && *C != '='; ++C) ; diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 5958000b460..e45f7528e22 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strftime.c,v 1.29 2015/12/25 19:10:29 mmcc Exp $ */ +/* $OpenBSD: strftime.c,v 1.30 2016/09/21 04:38:57 guenther Exp $ */ /* ** Copyright (c) 1989, 1993 ** The Regents of the University of California. All rights reserved. @@ -680,7 +680,7 @@ _loc(void) (void) strlcpy(lbuf, name, bufsize); p = lbuf + namesize; plim = p + st.st_size; - if (read(fd, p, (size_t) st.st_size) != st.st_size) + if (read(fd, p, st.st_size) != st.st_size) goto bad_lbuf; if (close(fd) != 0) goto bad_lbuf; |