summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/cp/utils.c2
-rw-r--r--lib/libc/db/recno/rec_open.c2
-rw-r--r--lib/libc/gen/nlist.c4
-rw-r--r--libexec/ftpd/ftpd.c2
-rw-r--r--libexec/lfs_cleanerd/library.c8
-rw-r--r--release/sysinstall/uc_main.c2
-rw-r--r--sbin/newfs/mkfs.c2
-rw-r--r--share/examples/meteor/rgb16.c4
-rw-r--r--share/examples/meteor/test-n.c4
-rw-r--r--share/examples/meteor/yuvpk.c4
-rw-r--r--share/examples/meteor/yuvpl.c4
-rw-r--r--share/man/man4/man4.i386/meteor.47
-rw-r--r--usr.bin/cmp/regular.c4
-rw-r--r--usr.bin/locate/locate/locate.c2
-rw-r--r--usr.bin/look/look.c2
-rw-r--r--usr.bin/strip/strip.c2
-rw-r--r--usr.bin/tail/forward.c2
-rw-r--r--usr.bin/tail/reverse.c2
-rw-r--r--usr.bin/xinstall/xinstall.c10
-rw-r--r--usr.bin/xlint/lint1/mem1.c2
-rw-r--r--usr.bin/xlint/lint2/mem2.c2
-rw-r--r--usr.sbin/config/main.c8
-rw-r--r--usr.sbin/ctm/mkCTM/mkctm.c6
-rw-r--r--usr.sbin/kvm_mkdb/nlist.c3
-rw-r--r--usr.sbin/rpc.statd/file.c2
25 files changed, 48 insertions, 44 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 762cedf..cda81f8 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -121,7 +121,7 @@ copy_file(entp, dne)
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
if (fs->st_size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
- 0, from_fd, (off_t)0)) == (char *)-1) {
+ MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
warn("%s", entp->fts_path);
rval = 1;
} else {
diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c
index 51d8a3c..8f8eff2 100644
--- a/lib/libc/db/recno/rec_open.c
+++ b/lib/libc/db/recno/rec_open.c
@@ -169,7 +169,7 @@ slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
t->bt_msize = sb.st_size;
if ((t->bt_smap = mmap(NULL, t->bt_msize,
PROT_READ, MAP_PRIVATE, rfd,
- (off_t)0)) == (caddr_t)-1)
+ (off_t)0)) == MAP_FAILED)
goto slow;
t->bt_cmap = t->bt_smap;
t->bt_emap = t->bt_smap + sb.st_size;
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index 7292452..7415cbe 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -99,8 +99,8 @@ __fdnlist(fd, list)
* without making the memory allocation permanent as with
* malloc/free (i.e., munmap will return it to the system).
*/
- a_out_mmap = mmap(NULL, (size_t)st.st_size, PROT_READ, 0, fd, (off_t)0);
- if (a_out_mmap == (char *)-1)
+ a_out_mmap = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0);
+ if (a_out_mmap == MAP_FAILED)
return (-1);
exec = (struct exec *)a_out_mmap;
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index ebe7dd3..71565cf 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1189,7 +1189,7 @@ send_data(instr, outstr, blksize, filesize, isreg)
if (isreg && filesize < (off_t)16 * 1024 * 1024) {
buf = mmap(0, filesize, PROT_READ, MAP_SHARED, filefd,
(off_t)0);
- if (!buf) {
+ if (buf == MAP_FAILED) {
syslog(LOG_WARNING, "mmap(%lu): %m",
(unsigned long)filesize);
goto oldway;
diff --git a/libexec/lfs_cleanerd/library.c b/libexec/lfs_cleanerd/library.c
index 9397f62..93951c6 100644
--- a/libexec/lfs_cleanerd/library.c
+++ b/libexec/lfs_cleanerd/library.c
@@ -204,8 +204,8 @@ get_ifile (fsp, use_mmap)
if (fsp->fi_cip)
munmap((caddr_t)fsp->fi_cip, fsp->fi_ifile_length);
ifp = mmap ((caddr_t)0, file_stat.st_size,
- PROT_READ|PROT_WRITE, 0, fid, (off_t)0);
- if (ifp == (caddr_t)(-1))
+ PROT_READ|PROT_WRITE, MAP_SHARED, fid, (off_t)0);
+ if (ifp == MAP_FAILED)
err(1, "get_ifile: mmap failed");
} else {
if (fsp->fi_cip)
@@ -541,8 +541,8 @@ mmap_segment (fsp, segment, segbuf, use_mmap)
if (use_mmap) {
*segbuf = mmap ((caddr_t)0, seg_size(lfsp), PROT_READ,
- 0, fid, seg_byte);
- if (*(long *)segbuf < 0) {
+ MAP_SHARED, fid, seg_byte);
+ if (*segbuf == MAP_FAILED) {
err(0, "mmap_segment: mmap failed");
return (NULL);
}
diff --git a/release/sysinstall/uc_main.c b/release/sysinstall/uc_main.c
index b6b9906..e66ceb9 100644
--- a/release/sysinstall/uc_main.c
+++ b/release/sysinstall/uc_main.c
@@ -190,7 +190,7 @@ uc_open(char *name){
kern->core = mmap((caddr_t)0, sb.st_size, PROT_READ | PROT_WRITE,
MAP_SHARED, kd, 0);
kern->incore = 0;
- if (kern->core == (caddr_t)0) {
+ if (kern->core == MAP_FAILED) {
free(kern);
msgDebug("uc_open: Unable to mmap from %s.\n", kname);
return NULL;
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 20d6832..e7504b0 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -183,7 +183,7 @@ mkfs(pp, fsys, fi, fo)
MAP_SHARED,
fd,
0);
- if((int)membase == -1) {
+ if(membase == MAP_FAILED) {
perror("mmap");
exit(12);
}
diff --git a/share/examples/meteor/rgb16.c b/share/examples/meteor/rgb16.c
index 17b1592..4c7ee07 100644
--- a/share/examples/meteor/rgb16.c
+++ b/share/examples/meteor/rgb16.c
@@ -77,9 +77,9 @@ main()
exit(1);
}
- rgb16 = (short *)mmap((caddr_t)0,SIZE,PROT_READ,0, i, (off_t)0);
+ rgb16 = (short *)mmap((caddr_t)0,SIZE,PROT_READ,MAP_SHARED, i, (off_t)0);
- if (rgb16 == (short *) -1) return (0);
+ if (rgb16 == (short *) MAP_FAILED) return (0);
c = METEOR_CAP_SINGLE ;
ioctl(i, METEORCAPTUR, &c);
diff --git a/share/examples/meteor/test-n.c b/share/examples/meteor/test-n.c
index f899033..4651654 100644
--- a/share/examples/meteor/test-n.c
+++ b/share/examples/meteor/test-n.c
@@ -127,9 +127,9 @@ main()
printf("mmap %d %d\n", errno, i);
size = ((width*height*depth*frames+4095)/4096)*4096;
- y=(uint8 *) mmap((caddr_t)0, size + 4096, PROT_READ |PROT_WRITE,0, i, (off_t)0);
+ y=(uint8 *) mmap((caddr_t)0, size + 4096, PROT_READ |PROT_WRITE,MAP_SHARED, i, (off_t)0);
- if (y == (uint8 *) -1) return (0);
+ if (y == (uint8 *) MAP_FAILED) return (0);
common_mem = (struct meteor_mem *) (y + size);
diff --git a/share/examples/meteor/yuvpk.c b/share/examples/meteor/yuvpk.c
index b2941e0..6ebd2e4 100644
--- a/share/examples/meteor/yuvpk.c
+++ b/share/examples/meteor/yuvpk.c
@@ -81,9 +81,9 @@ main()
exit(1);
}
- yuv_data = (uint8 *)mmap((caddr_t)0,SIZE,PROT_READ,0, i, (off_t)0);
+ yuv_data = (uint8 *)mmap((caddr_t)0,SIZE,PROT_READ,MAP_SHARED, i, (off_t)0);
- if (yuv_data == (int8 *) -1) return (0);
+ if (yuv_data == (int8 *) MAP_FAILED) return (0);
c = METEOR_CAP_SINGLE ;
ioctl(i, METEORCAPTUR, &c);
diff --git a/share/examples/meteor/yuvpl.c b/share/examples/meteor/yuvpl.c
index 243644d..704dfce 100644
--- a/share/examples/meteor/yuvpl.c
+++ b/share/examples/meteor/yuvpl.c
@@ -84,9 +84,9 @@ main()
exit(1);
}
- yuv_data = (uint8 *)mmap((caddr_t)0,SIZE,PROT_READ,0, i, (off_t)0);
+ yuv_data = (uint8 *)mmap((caddr_t)0,SIZE,PROT_READ,MAP_SHARED, i, (off_t)0);
- if (yuv_data == (uint8 *) -1) return (0);
+ if (yuv_data == (uint8 *) MAP_FAILED) return (0);
temp = ROWS * COLS;
ue = yuv_data + temp;
diff --git a/share/man/man4/man4.i386/meteor.4 b/share/man/man4/man4.i386/meteor.4
index add769c..879e573 100644
--- a/share/man/man4/man4.i386/meteor.4
+++ b/share/man/man4/man4.i386/meteor.4
@@ -233,7 +233,8 @@ main()
exit(1);
}
- mmbuf=(char *)mmap((caddr_t)0, SIZE, PROT_READ, 0, i, (off_t)0);
+ mmbuf=(char *)mmap((caddr_t)0, SIZE, PROT_READ,
+ MAP_SHARED, i, (off_t)0);
#ifdef SINGLE_MODE
/* single frame capture */
@@ -405,9 +406,9 @@ main()
size = ((width*height*depth*frames+4095)/4096)*4096;
/* add one page after data for meteor_mem */
data_frames = mmap((caddr_t)0, size + 4096, PROT_READ | PROT_WRITE,
- 0, i, (off_t)0);
+ MAP_SHARED, i, (off_t)0);
- if (data_frames == (caddr_t) -1) return (0);
+ if (data_frames == (caddr_t) MAP_FAILED) return (0);
/* common_mem is located at page following data */
common_mem = (struct meteor_mem *) (y + size);
diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c
index 5d301fa..f540ab4 100644
--- a/usr.bin/cmp/regular.c
+++ b/usr.bin/cmp/regular.c
@@ -80,12 +80,12 @@ c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2)
return (c_special(fd1, file1, skip1, fd2, file2, skip2));
if ((p1 = (u_char *)mmap(NULL,
- (size_t)length, PROT_READ, 0, fd1, off1)) == (u_char *)-1)
+ (size_t)length, PROT_READ, MAP_SHARED, fd1, off1)) == (u_char *)MAP_FAILED)
err(ERR_EXIT, "%s", file1);
madvise(p1, length, MADV_SEQUENTIAL);
if ((p2 = (u_char *)mmap(NULL,
- (size_t)length, PROT_READ, 0, fd2, off2)) == (u_char *)-1)
+ (size_t)length, PROT_READ, MAP_SHARED, fd2, off2)) == (u_char *)MAP_FAILED)
err(ERR_EXIT, "%s", file2);
madvise(p2, length, MADV_SEQUENTIAL);
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index 427d49d..791c3eb 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -301,7 +301,7 @@ search_mmap(db, s)
if ((p = mmap((caddr_t)0, (size_t)len,
PROT_READ, MAP_SHARED,
- fd, (off_t)0)) == (caddr_t)-1)
+ fd, (off_t)0)) == MAP_FAILED)
err(1, "mmap ``%s''", path_fcodes);
/* foreach search string ... */
diff --git a/usr.bin/look/look.c b/usr.bin/look/look.c
index e2bd952..daef12f 100644
--- a/usr.bin/look/look.c
+++ b/usr.bin/look/look.c
@@ -143,7 +143,7 @@ main(argc, argv)
if (sb.st_size > SIZE_T_MAX)
err("%s: %s", file, strerror(EFBIG));
if ((front = mmap(NULL,
- (size_t)sb.st_size, PROT_READ, 0, fd, (off_t)0)) == NULL)
+ (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
err("%s: %s", file, strerror(errno));
back = front + sb.st_size;
exit(look(string, front, back));
diff --git a/usr.bin/strip/strip.c b/usr.bin/strip/strip.c
index 8fe4c49..36f14c2 100644
--- a/usr.bin/strip/strip.c
+++ b/usr.bin/strip/strip.c
@@ -173,7 +173,7 @@ s_stab(fn, fd, ep)
/* Map the file. */
if ((ep = (EXEC *)mmap(NULL, (size_t)sb.st_size,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0)) == (EXEC *)-1) {
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0)) == (EXEC *)MAP_FAILED) {
err(0, "%s: %s", fn, strerror(errno));
return;
}
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index 4b22eef..b9457af 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -210,7 +210,7 @@ rlines(fp, off, sbp)
}
if ((start = mmap(NULL, (size_t)size,
- PROT_READ, 0, fileno(fp), (off_t)0)) == (caddr_t)-1) {
+ PROT_READ, MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) {
ierr();
return;
}
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 2653add..0a07f4f 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -125,7 +125,7 @@ r_reg(fp, style, off, sbp)
}
if ((start = mmap(NULL, (size_t)size,
- PROT_READ, 0, fileno(fp), (off_t)0)) == (caddr_t)-1) {
+ PROT_READ, MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) {
ierr();
return;
}
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 9a2a991..0148958 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -513,11 +513,11 @@ compare(int from_fd, const char *from_name, int to_fd, const char *to_name,
if (tsize <= 8 * 1024 * 1024) {
done_compare = 0;
if (trymmap(from_fd) && trymmap(to_fd)) {
- p = mmap(NULL, tsize, PROT_READ, 0, from_fd, (off_t)0);
- if ((long)p == -1)
+ p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0);
+ if (p == (char *)MAP_FAILED)
goto out;
- q = mmap(NULL, tsize, PROT_READ, 0, to_fd, (off_t)0);
- if ((long)q == -1) {
+ q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0);
+ if (q == (char *)MAP_FAILED) {
munmap(p, tsize);
goto out;
}
@@ -581,7 +581,7 @@ copy(from_fd, from_name, to_fd, to_name, size)
done_copy = 0;
if (size <= 8 * 1048576 && trymmap(from_fd)) {
if ((p = mmap(NULL, (size_t)size, PROT_READ,
- 0, from_fd, (off_t)0)) == (char *)-1)
+ MAP_SHARED, from_fd, (off_t)0)) == (char *)MAP_FAILED)
goto out;
if ((nw = write(to_fd, p, size)) != size) {
serrno = errno;
diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c
index df880b1..f3bf3c6 100644
--- a/usr.bin/xlint/lint1/mem1.c
+++ b/usr.bin/xlint/lint1/mem1.c
@@ -180,7 +180,7 @@ xnewblk()
prot = PROT_READ | PROT_WRITE;
flags = MAP_ANON | MAP_PRIVATE;
mb->blk = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
- if (mb->blk == (void *)-1)
+ if (mb->blk == (void *)MAP_FAILED)
err(1, "can't map memory");
if (ALIGN((u_long)mb->blk) != (u_long)mb->blk)
errx(1, "mapped address is not aligned");
diff --git a/usr.bin/xlint/lint2/mem2.c b/usr.bin/xlint/lint2/mem2.c
index 06d7491..ed97c6f 100644
--- a/usr.bin/xlint/lint2/mem2.c
+++ b/usr.bin/xlint/lint2/mem2.c
@@ -82,7 +82,7 @@ xalloc(sz)
prot = PROT_READ | PROT_WRITE;
flags = MAP_ANON | MAP_PRIVATE;
mbuf = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
- if (mbuf == (void *)-1)
+ if (mbuf == (void *)MAP_FAILED)
err(1, "can't map memory");
if (ALIGN((u_long)mbuf) != (u_long)mbuf)
errx(1, "mapped address is not aligned");
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 4d3cccb..3e6778f 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -405,11 +405,11 @@ moveifchanged(const char *from_name, const char *to_name)
tsize = (size_t)from_sb.st_size;
if (!changed) {
- p = mmap(NULL, tsize, PROT_READ, 0, from_fd, (off_t)0);
- if ((long)p == -1)
+ p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0);
+ if (p == MAP_FAILED)
err(EX_OSERR, "mmap %s", from_name);
- q = mmap(NULL, tsize, PROT_READ, 0, to_fd, (off_t)0);
- if ((long)q == -1)
+ q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0);
+ if (q == MAP_FAILED)
err(EX_OSERR, "mmap %s", to_name);
changed = memcmp(p, q, tsize);
diff --git a/usr.sbin/ctm/mkCTM/mkctm.c b/usr.sbin/ctm/mkCTM/mkctm.c
index 24c3aaa..698d114 100644
--- a/usr.sbin/ctm/mkCTM/mkctm.c
+++ b/usr.sbin/ctm/mkCTM/mkctm.c
@@ -179,11 +179,11 @@ Equ(const char *dir1, const char *dir2, const char *name, struct dirent *de)
}
#endif
p1=mmap(0, s1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0);
- if ((int)p1 == -1) { perror(buf1); exit(3); }
+ if (p1 == (u_char *)MAP_FAILED) { perror(buf1); exit(3); }
close(fd1);
p2=mmap(0, s2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0);
- if ((int)p2 == -1) { perror(buf2); exit(3); }
+ if (p2 == (u_char *)MAP_FAILED) { perror(buf2); exit(3); }
close(fd2);
/* If identical, we're done. */
@@ -322,7 +322,7 @@ Add(const char *dir1, const char *dir2, const char *name, struct dirent *de)
if (fd1 < 0) {perror(buf2); exit (3); }
fstat(fd1, &st);
p1=mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd1, 0);
- if ((int)p1 == -1) { perror(buf2); exit(3); }
+ if (p1 == (u_char *)MAP_FAILED) { perror(buf2); exit(3); }
close(fd1);
m2 = MD5Data(p1, st.st_size, md5_2);
name_stat("CTMFM", dir2, name, de);
diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c
index adf4a42..58d66fa 100644
--- a/usr.sbin/kvm_mkdb/nlist.c
+++ b/usr.sbin/kvm_mkdb/nlist.c
@@ -88,6 +88,9 @@ create_knlist(name, db)
filep = (u_char*)mmap(0, sst.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (filep == (u_char*)MAP_FAILED)
+ err(1, "mmap failed");
+
/* Read in exec structure. */
ebuf = (struct exec *) filep;
diff --git a/usr.sbin/rpc.statd/file.c b/usr.sbin/rpc.statd/file.c
index aeb1fc0..5dbc1cac 100644
--- a/usr.sbin/rpc.statd/file.c
+++ b/usr.sbin/rpc.statd/file.c
@@ -158,7 +158,7 @@ void init_file(char *filename)
status_info = (FileLayout *)
mmap(NULL, 0x10000000, PROT_READ | PROT_WRITE, MAP_SHARED, status_fd, 0);
- if (status_info == (FileLayout *) -1)
+ if (status_info == (FileLayout *) MAP_FAILED)
{
perror("rpc.statd");
fprintf(stderr, "Unable to mmap() status file\n");
OpenPOWER on IntegriCloud