SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX.
- todd
Index: lib/libc/gen/nlist.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/nlist.c,v
retrieving revision 1.58
diff -u -r1.58 nlist.c
--- lib/libc/gen/nlist.c 16 Jan 2015 16:48:51 -0000 1.58
+++ lib/libc/gen/nlist.c 6 Feb 2015 21:23:14 -0000
@@ -34,11 +34,11 @@
#include <errno.h>
#include <fcntl.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
#include <a.out.h> /* pulls in nlist.h */
#ifdef _NLIST_DO_ELF
@@ -111,7 +111,7 @@
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
/* Make sure it's not too big to mmap */
- if (shdr_size > SIZE_T_MAX) {
+ if (shdr_size > SIZE_MAX) {
errno = EFBIG;
return (-1);
}
@@ -154,7 +154,7 @@
/* Check for files too large to mmap. */
/* XXX is this really possible? */
- if (symstrsize > SIZE_T_MAX) {
+ if (symstrsize > SIZE_MAX) {
errno = EFBIG;
return (-1);
}
Index: lib/libc/gen/getusershell.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/getusershell.c,v
retrieving revision 1.14
diff -u -r1.14 getusershell.c
--- lib/libc/gen/getusershell.c 15 Sep 2014 06:15:48 -0000 1.14
+++ lib/libc/gen/getusershell.c 6 Feb 2015 21:23:35 -0000
@@ -33,6 +33,7 @@
#include <ctype.h>
#include <limits.h>
#include <paths.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -101,7 +102,7 @@
(void)fclose(fp);
return (okshells);
}
- if (statb.st_size > SIZE_T_MAX) {
+ if (statb.st_size > SIZE_MAX) {
(void)fclose(fp);
return (okshells);
}
Index: lib/libc/stdio/getdelim.c
===================================================================
RCS file: /cvs/src/lib/libc/stdio/getdelim.c,v
retrieving revision 1.2
diff -u -r1.2 getdelim.c
--- lib/libc/stdio/getdelim.c 16 Oct 2014 17:31:51 -0000 1.2
+++ lib/libc/stdio/getdelim.c 6 Feb 2015 21:24:14 -0000
@@ -30,6 +30,7 @@
#include <errno.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -96,7 +97,7 @@
newlen |= newlen >> 4;
newlen |= newlen >> 8;
newlen |= newlen >> 16;
-#if SIZE_T_MAX > 0xffffffffU
+#if SIZE_MAX > 0xffffffffU
newlen |= newlen >> 32;
#endif
newlen++;
Index: lib/libedit/readline.c
===================================================================
RCS file: /cvs/src/lib/libedit/readline.c,v
retrieving revision 1.13
diff -u -r1.13 readline.c
--- lib/libedit/readline.c 13 Jan 2015 08:33:12 -0000 1.13
+++ lib/libedit/readline.c 6 Feb 2015 21:24:39 -0000
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <stdint.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
@@ -2133,7 +2134,7 @@
}
qsort(&list[1], len - 1, sizeof(*list),
(int (*)(const void *, const void *)) strcmp);
- min = SIZE_T_MAX;
+ min = SIZE_MAX;
for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
b = list[i + 1];
for (j = 0; a[j] && a[j] == b[j]; j++)
Index: lib/libfuse/fuse_opt.c
===================================================================
RCS file: /cvs/src/lib/libfuse/fuse_opt.c,v
retrieving revision 1.11
diff -u -r1.11 fuse_opt.c
--- lib/libfuse/fuse_opt.c 8 Oct 2014 04:50:10 -0000 1.11
+++ lib/libfuse/fuse_opt.c 6 Feb 2015 21:24:55 -0000
@@ -17,6 +17,7 @@
*/
#include <assert.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -174,7 +175,7 @@
while (*s) {
/* malloc(size + escaped) overflow check */
- if (size >= (SIZE_T_MAX / 2))
+ if (size >= (SIZE_MAX / 2))
return (-1);
if (*s == ',' || *s == '\\')
Index: libexec/ftpd/monitor.c
===================================================================
RCS file: /cvs/src/libexec/ftpd/monitor.c,v
retrieving revision 1.21
diff -u -r1.21 monitor.c
--- libexec/ftpd/monitor.c 25 Aug 2014 07:50:25 -0000 1.21
+++ libexec/ftpd/monitor.c 6 Feb 2015 21:25:14 -0000
@@ -23,11 +23,11 @@
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
#include <paths.h>
#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -266,7 +266,7 @@
debugmsg("CMD_USER received");
recv_data(fd_slave, &len, sizeof(len));
- if (len == SIZE_T_MAX)
+ if (len == SIZE_MAX)
fatalx("monitor received invalid user length");
if ((name = malloc(len + 1)) == NULL)
fatalx("malloc: %m");
@@ -281,7 +281,7 @@
debugmsg("CMD_PASS received");
recv_data(fd_slave, &len, sizeof(len));
- if (len == SIZE_T_MAX)
+ if (len == SIZE_MAX)
fatalx("monitor received invalid pass length");
if ((pw = malloc(len + 1)) == NULL)
fatalx("malloc: %m");
Index: regress/lib/libc/db/dbtest.c
===================================================================
RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v
retrieving revision 1.12
diff -u -r1.12 dbtest.c
--- regress/lib/libc/db/dbtest.c 27 Oct 2009 23:59:32 -0000 1.12
+++ regress/lib/libc/db/dbtest.c 6 Feb 2015 21:25:56 -0000
@@ -36,7 +36,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -685,10 +685,8 @@
if ((fd = open(name, O_RDONLY, 0)) < 0 ||
fstat(fd, &sb))
dberr("%s: %s\n", name, strerror(errno));
-#ifdef NOT_PORTABLE
- if (sb.st_size > (off_t)SIZE_T_MAX)
+ if (sb.st_size > (off_t)SIZE_MAX)
dberr("%s: %s\n", name, strerror(E2BIG));
-#endif
if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
dberr("%s", strerror(errno));
(void)read(fd, p, (int)sb.st_size);
Index: regress/sys/uvm/mmap_size/mmap_size.c
===================================================================
RCS file: /cvs/src/regress/sys/uvm/mmap_size/mmap_size.c,v
retrieving revision 1.2
diff -u -r1.2 mmap_size.c
--- regress/sys/uvm/mmap_size/mmap_size.c 14 Mar 2006 09:31:51 -0000
1.2
+++ regress/sys/uvm/mmap_size/mmap_size.c 6 Feb 2015 21:26:09 -0000
@@ -7,9 +7,9 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <err.h>
-#include <limits.h>
-#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
void
f(size_t sz)
@@ -37,7 +37,7 @@
for (i = 0; i < 0x2000; i += 0x100) {
f(i);
f(-i);
- f(SIZE_T_MAX/2 - 0x1000);
+ f(SIZE_MAX/2 - 0x1000);
}
return (0);
}
Index: usr.bin/cmp/regular.c
===================================================================
RCS file: /cvs/src/usr.bin/cmp/regular.c,v
retrieving revision 1.11
diff -u -r1.11 regular.c
--- usr.bin/cmp/regular.c 16 Jan 2015 06:40:06 -0000 1.11
+++ usr.bin/cmp/regular.c 6 Feb 2015 21:30:29 -0000
@@ -34,7 +34,7 @@
#include <sys/stat.h>
#include <err.h>
-#include <limits.h>
+#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -62,7 +62,7 @@
len2 -= skip2;
length = MINIMUM(len1, len2);
- if (length > SIZE_T_MAX) {
+ if (length > SIZE_MAX) {
mmap_failed:
c_special(fd1, file1, skip1, fd2, file2, skip2);
return;
Index: usr.bin/grep/mmfile.c
===================================================================
RCS file: /cvs/src/usr.bin/grep/mmfile.c,v
retrieving revision 1.16
diff -u -r1.16 mmfile.c
--- usr.bin/grep/mmfile.c 16 Jan 2015 06:40:08 -0000 1.16
+++ usr.bin/grep/mmfile.c 6 Feb 2015 21:30:38 -0000
@@ -54,7 +54,7 @@
goto ouch1;
if (fstat(mmf->fd, &st) == -1)
goto ouch2;
- if (st.st_size > SIZE_T_MAX) /* too big to mmap */
+ if (st.st_size > SIZE_MAX) /* too big to mmap */
goto ouch2;
if (!S_ISREG(st.st_mode)) /* only mmap regular files */
goto ouch2;
Index: usr.bin/look/look.c
===================================================================
RCS file: /cvs/src/usr.bin/look/look.c,v
retrieving revision 1.15
diff -u -r1.15 look.c
--- usr.bin/look/look.c 20 May 2014 01:25:23 -0000 1.15
+++ usr.bin/look/look.c 6 Feb 2015 21:32:08 -0000
@@ -48,7 +48,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -126,7 +126,7 @@
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
err(2, "%s", file);
- if (sb.st_size > SIZE_T_MAX)
+ if (sb.st_size > SIZE_MAX)
errc(2, EFBIG, "%s", file);
if ((front = mmap(NULL,
(size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0)) ==
MAP_FAILED)
Index: usr.bin/nm/elf.c
===================================================================
RCS file: /cvs/src/usr.bin/nm/elf.c,v
retrieving revision 1.25
diff -u -r1.25 elf.c
--- usr.bin/nm/elf.c 19 Jan 2015 20:25:36 -0000 1.25
+++ usr.bin/nm/elf.c 6 Feb 2015 21:32:19 -0000
@@ -32,10 +32,10 @@
#include <elf_abi.h>
#include <errno.h>
#include <err.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
#include <ctype.h>
#include "elfuncs.h"
#include "util.h"
@@ -454,7 +454,7 @@
for (i = 0; i < eh->e_shnum; i++) {
if (!strcmp(shstr + shdr[i].sh_name, strtab)) {
*pstabsize = shdr[i].sh_size;
- if (*pstabsize > SIZE_T_MAX) {
+ if (*pstabsize > SIZE_MAX) {
warnx("%s: corrupt file", name);
return (1);
}
Index: usr.bin/spell/spellprog.c
===================================================================
RCS file: /cvs/src/usr.bin/spell/spellprog.c,v
retrieving revision 1.9
diff -u -r1.9 spellprog.c
--- usr.bin/spell/spellprog.c 16 Jan 2015 06:40:12 -0000 1.9
+++ usr.bin/spell/spellprog.c 6 Feb 2015 21:32:35 -0000
@@ -73,6 +73,7 @@
#include <fcntl.h>
#include <limits.h>
#include <locale.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -283,7 +284,7 @@
wlists[i].fd = open(argv[i], O_RDONLY, 0);
if (wlists[i].fd == -1 || fstat(wlists[i].fd, &sb) != 0)
err(1, "%s", argv[i]);
- if (sb.st_size > SIZE_T_MAX)
+ if (sb.st_size > SIZE_MAX)
errc(1, EFBIG, "%s", argv[i]);
wlists[i].front = mmap(NULL, (size_t)sb.st_size, PROT_READ,
MAP_PRIVATE, wlists[i].fd, (off_t)0);
Index: usr.bin/ssh/xmalloc.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/xmalloc.c,v
retrieving revision 1.30
diff -u -r1.30 xmalloc.c
--- usr.bin/ssh/xmalloc.c 16 Jan 2015 06:40:12 -0000 1.30
+++ usr.bin/ssh/xmalloc.c 6 Feb 2015 21:32:58 -0000
@@ -14,10 +14,10 @@
*/
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
#include "xmalloc.h"
#include "log.h"
@@ -42,8 +42,8 @@
if (size == 0 || nmemb == 0)
fatal("xcalloc: zero size");
- if (SIZE_T_MAX / nmemb < size)
- fatal("xcalloc: nmemb * size > SIZE_T_MAX");
+ if (SIZE_MAX / nmemb < size)
+ fatal("xcalloc: nmemb * size > SIZE_MAX");
ptr = calloc(nmemb, size);
if (ptr == NULL)
fatal("xcalloc: out of memory (allocating %zu bytes)",
@@ -59,8 +59,8 @@
if (new_size == 0)
fatal("xrealloc: zero size");
- if (SIZE_T_MAX / nmemb < size)
- fatal("xrealloc: nmemb * size > SIZE_T_MAX");
+ if (SIZE_MAX / nmemb < size)
+ fatal("xrealloc: nmemb * size > SIZE_MAX");
if (ptr == NULL)
new_ptr = malloc(new_size);
else
Index: usr.bin/ssh/channels.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/channels.c,v
retrieving revision 1.340
diff -u -r1.340 channels.c
--- usr.bin/ssh/channels.c 20 Jan 2015 23:14:00 -0000 1.340
+++ usr.bin/ssh/channels.c 6 Feb 2015 21:33:22 -0000
@@ -54,12 +54,12 @@
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
-#include <limits.h>
#include <stdarg.h>
#include "xmalloc.h"
@@ -2159,7 +2159,7 @@
nfdset = howmany(n+1, NFDBITS);
/* Explicitly test here, because xrealloc isn't always called */
- if (nfdset && SIZE_T_MAX / nfdset < sizeof(fd_mask))
+ if (nfdset && SIZE_MAX / nfdset < sizeof(fd_mask))
fatal("channel_prepare_select: max_fd (%d) is too large", n);
sz = nfdset * sizeof(fd_mask);
Index: usr.bin/ssh/monitor_mm.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/monitor_mm.c,v
retrieving revision 1.20
diff -u -r1.20 monitor_mm.c
--- usr.bin/ssh/monitor_mm.c 20 Jan 2015 23:14:00 -0000 1.20
+++ usr.bin/ssh/monitor_mm.c 6 Feb 2015 21:33:38 -0000
@@ -31,9 +31,9 @@
#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
#include "xmalloc.h"
#include "ssh.h"
@@ -168,7 +168,7 @@
if (size == 0)
fatal("mm_malloc: try to allocate 0 space");
- if (size > SIZE_T_MAX - MM_MINSIZE + 1)
+ if (size > SIZE_MAX - MM_MINSIZE + 1)
fatal("mm_malloc: size too big");
size = ((size + (MM_MINSIZE - 1)) / MM_MINSIZE) * MM_MINSIZE;
Index: usr.bin/ssh/monitor.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/monitor.c,v
retrieving revision 1.141
diff -u -r1.141 monitor.c
--- usr.bin/ssh/monitor.c 20 Jan 2015 23:14:00 -0000 1.141
+++ usr.bin/ssh/monitor.c 6 Feb 2015 21:33:52 -0000
@@ -42,10 +42,10 @@
#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
#include "atomicio.h"
#include "xmalloc.h"
@@ -394,7 +394,7 @@
size_t len = (size_t) size * ncount;
void *address;
- if (len == 0 || ncount > SIZE_T_MAX / size)
+ if (len == 0 || ncount > SIZE_MAX / size)
fatal("%s: mm_zalloc(%u, %u)", __func__, ncount, size);
address = mm_malloc(mm, len);
Index: usr.bin/tail/read.c
===================================================================
RCS file: /cvs/src/usr.bin/tail/read.c,v
retrieving revision 1.14
diff -u -r1.14 read.c
--- usr.bin/tail/read.c 27 Oct 2009 23:59:44 -0000 1.14
+++ usr.bin/tail/read.c 6 Feb 2015 21:34:04 -0000
@@ -35,10 +35,10 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/limits.h>
#include <err.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -67,7 +67,7 @@
int wrap;
char *sp;
- if (off > SIZE_T_MAX)
+ if (off > SIZE_MAX)
errx(1, "offset too large");
if ((sp = p = malloc(off)) == NULL)
@@ -148,7 +148,7 @@
size_t cnt, recno, blen, newsize;
char *sp = NULL, *newp = NULL;
- if (off > SIZE_T_MAX)
+ if (off > SIZE_MAX)
errx(1, "offset too large");
if ((lines = calloc(off, sizeof(*lines))) == NULL)
Index: usr.sbin/snmpd/pf.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/pf.c,v
retrieving revision 1.9
diff -u -r1.9 pf.c
--- usr.sbin/snmpd/pf.c 21 Jan 2015 21:50:33 -0000 1.9
+++ usr.sbin/snmpd/pf.c 6 Feb 2015 21:38:26 -0000
@@ -43,11 +43,11 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
#include <event.h>
#include "snmpd.h"
@@ -145,7 +145,7 @@
} else {
if (minsize == 0)
minsize = b->pfrb_msize * 2;
- if (minsize < 0 || (size_t)minsize >= SIZE_T_MAX / bs) {
+ if (minsize < 0 || (size_t)minsize >= SIZE_MAX / bs) {
/* msize overflow */
return (-1);
}