Hi, The diff below fixes several signed vs unsigned type confusion warnings and shuffles some assignments around.
.joris Index: buf.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/buf.c,v retrieving revision 1.83 diff -u -p -r1.83 buf.c --- buf.c 5 Nov 2015 09:48:21 -0000 1.83 +++ buf.c 22 Jun 2016 09:52:04 -0000 @@ -106,7 +106,7 @@ buf_load_fd(int fd) if (lseek(fd, 0, SEEK_SET) == -1) fatal("buf_load_fd: lseek: %s", strerror(errno)); - if (st.st_size > SIZE_MAX) + if ((uintmax_t)st.st_size > SIZE_MAX) fatal("buf_load_fd: file size too big"); buf = buf_alloc(st.st_size); if (atomicio(read, fd, buf->cb_buf, buf->cb_size) != buf->cb_size) Index: diff3.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/diff3.c,v retrieving revision 1.59 diff -u -p -r1.59 diff3.c --- diff3.c 5 Nov 2015 09:48:21 -0000 1.59 +++ diff3.c 22 Jun 2016 09:52:04 -0000 @@ -295,7 +295,8 @@ diff3_internal(int argc, char **argv, co free(overlap); free(de); - de = d13 = d23 = overlap = NULL; + overlap = NULL; + de = d13 = d23 = NULL; increase(); @@ -793,7 +794,7 @@ edscript(int n) (void)fseek(fp[2], (long)de[n].new.from, SEEK_SET); for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) { j = k > BUFSIZ ? BUFSIZ : k; - if (fread(block, 1, j, fp[2]) != j) + if (fread(block, 1, j, fp[2]) != (size_t)j) return (-1); block[j] = '\0'; diff_output("%s", block); Index: diff_internals.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/diff_internals.c,v retrieving revision 1.38 diff -u -p -r1.38 diff_internals.c --- diff_internals.c 5 Nov 2015 09:48:21 -0000 1.38 +++ diff_internals.c 22 Jun 2016 09:52:04 -0000 @@ -455,13 +455,17 @@ prepare(int i, FILE *fd, off_t filesize, rewind(fd); - sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25; + if ((uintmax_t)filesize <= SIZE_MAX) + sz = filesize / 25; + else + sz = SIZE_MAX / 25; + if (sz < 100) sz = 100; p = xcalloc(sz + 3, sizeof(*p)); for (j = 0; (h = readhash(fd, flags));) { - if (j == sz) { + if ((size_t)j == sz) { sz = sz * 3 / 2; p = xreallocarray(p, sz + 3, sizeof(*p)); } Index: file.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.267 diff -u -p -r1.267 file.c --- file.c 5 Nov 2015 09:48:21 -0000 1.267 +++ file.c 22 Jun 2016 09:52:04 -0000 @@ -461,12 +461,13 @@ cvs_file_walkdir(struct cvs_file *cf, st fatal("cvs_file_walkdir: %s %s", cf->file_path, strerror(errno)); - if (st.st_size > SIZE_MAX) + if ((uintmax_t)st.st_size > SIZE_MAX) fatal("cvs_file_walkdir: %s: file size too big", cf->file_name); - bufsize = st.st_size; - if (bufsize < st.st_blksize) + if (st.st_size < st.st_blksize) bufsize = st.st_blksize; + else + bufsize = st.st_size; buf = xmalloc(bufsize); RB_INIT(&fl); @@ -1032,7 +1033,7 @@ cvs_file_cmp(const char *file1, const ch if (S_ISREG(stb1.st_mode)) { void *p1, *p2; - if (stb1.st_size > SIZE_MAX) { + if ((uintmax_t)stb1.st_size > SIZE_MAX) { ret = 1; goto out; } @@ -1087,28 +1088,31 @@ cvs_file_copy(const char *from, const ch if (S_ISREG(st.st_mode)) { char *p; + size_t len; int saved_errno; - if (st.st_size > SIZE_MAX) { + if ((uintmax_t)st.st_size > SIZE_MAX) { ret = -1; goto out; } + len = st.st_size; + if ((dst = open(to, O_CREAT|O_TRUNC|O_WRONLY, st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO))) == -1) fatal("cvs_file_copy: open `%s': %s", to, strerror(errno)); - if ((p = mmap(NULL, st.st_size, PROT_READ, + if ((p = mmap(NULL, len, PROT_READ, MAP_FILE, src, (off_t)0)) == MAP_FAILED) { saved_errno = errno; (void)unlink(to); fatal("cvs_file_copy: mmap: %s", strerror(saved_errno)); } - madvise(p, st.st_size, MADV_SEQUENTIAL); + madvise(p, len, MADV_SEQUENTIAL); - if (atomicio(vwrite, dst, p, st.st_size) != st.st_size) { + if (atomicio(vwrite, dst, p, len) != len) { saved_errno = errno; (void)unlink(to); fatal("cvs_file_copy: `%s': %s", from, Index: logmsg.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/logmsg.c,v retrieving revision 1.57 diff -u -p -r1.57 logmsg.c --- logmsg.c 5 Nov 2015 09:48:21 -0000 1.57 +++ logmsg.c 22 Jun 2016 09:52:04 -0000 @@ -59,7 +59,7 @@ cvs_logmsg_read(const char *path) if ((fp = fdopen(fd, "r")) == NULL) fatal("cvs_logmsg_read: fdopen %s", strerror(errno)); - if (st.st_size > SIZE_MAX) + if ((uintmax_t)st.st_size > SIZE_MAX) fatal("cvs_logmsg_read: %s: file size too big", path); lbuf = NULL; @@ -142,9 +142,10 @@ cvs_logmsg_create(char *dir, struct cvs_ if ((rp = fdopen(rd, "r")) == NULL) fatal("cvs_logmsg_create: fdopen %s", strerror(errno)); - if (st.st_size > SIZE_MAX) + if ((uintmax_t)st.st_size > SIZE_MAX) { fatal("cvs_logmsg_create: %s: file size " "too big", line->line); + } logmsg = xmalloc(st.st_size); fread(logmsg, st.st_size, 1, rp); fwrite(logmsg, st.st_size, 1, fp); Index: update.c =================================================================== RCS file: /cvs/src/usr.bin/cvs/update.c,v retrieving revision 1.171 diff -u -p -r1.171 update.c --- update.c 5 Nov 2015 09:48:21 -0000 1.171 +++ update.c 22 Jun 2016 09:52:04 -0000 @@ -259,13 +259,15 @@ cvs_update_leavedir(struct cvs_file *cf) if (fstat(cf->fd, &st) == -1) fatal("cvs_update_leavedir: %s", strerror(errno)); - bufsize = st.st_size; - if (bufsize < st.st_blksize) - bufsize = st.st_blksize; - - if (st.st_size > SIZE_MAX) + if ((uintmax_t)st.st_size > SIZE_MAX) { fatal("cvs_update_leavedir: %s: file size too big", cf->file_name); + } + + if (st.st_size < st.st_blksize) + bufsize = st.st_blksize; + else + bufsize = st.st_size; isempty = 1; buf = xmalloc(bufsize);