From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Fix previous: mmap(2) returns MAP_FAILED on failure, not NULL.
Date: Sat, 26 Aug 2017 15:38:44 -0500 (EST) [thread overview]
Message-ID: <13909620224553425838.enqueue@fantadrom.bsd.lv> (raw)
Log Message:
-----------
Fix previous: mmap(2) returns MAP_FAILED on failure, not NULL.
Bug pointed out by tedu@.
Modified Files:
--------------
mandoc:
mandocdb.c
Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v
retrieving revision 1.255
retrieving revision 1.256
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.255 -r1.256
--- mandocdb.c
+++ mandocdb.c
@@ -2152,7 +2152,7 @@ dbwrite(struct dba *dba)
say("", "&%s", tfn);
return;
}
- cp1 = cp2 = NULL;
+ cp1 = cp2 = MAP_FAILED;
fd1 = fd2 = -1;
(void)strlcat(tfn, "/" MANDOC_DB, sizeof(tfn));
if (dba_write(tfn, dba) == -1) {
@@ -2178,12 +2178,12 @@ dbwrite(struct dba *dba)
if (sb1.st_size != sb2.st_size)
goto err;
if ((cp1 = mmap(NULL, sb1.st_size, PROT_READ, MAP_PRIVATE,
- fd1, 0)) == NULL) {
+ fd1, 0)) == MAP_FAILED) {
say(MANDOC_DB, "&mmap");
goto err;
}
if ((cp2 = mmap(NULL, sb2.st_size, PROT_READ, MAP_PRIVATE,
- fd2, 0)) == NULL) {
+ fd2, 0)) == MAP_FAILED) {
say(tfn, "&mmap");
goto err;
}
@@ -2197,9 +2197,9 @@ err:
say(MANDOC_DB, "Data changed, but cannot replace database");
out:
- if (cp1 != NULL)
+ if (cp1 != MAP_FAILED)
munmap(cp1, sb1.st_size);
- if (cp2 != NULL)
+ if (cp2 != MAP_FAILED)
munmap(cp2, sb2.st_size);
if (fd1 != -1)
close(fd1);
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2017-08-26 20:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13909620224553425838.enqueue@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).