summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-12-15 17:38:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-12-15 17:38:45 +0000
commitf0d907b5ddcf8c6632e2f8c3301b9ef19abc0a02 (patch)
treeff9a80d2c3722497da3f61fc232083562c4f7945
parentcd024781e6da76dda541a980fc161f031b33e300 (diff)
downloadmandoc-f0d907b5ddcf8c6632e2f8c3301b9ef19abc0a02.tar.gz
pledge(2) style:
Make sure to always use the idiom 'if (pledge("' such that it can easily be searched for. No functional change. Requested by deraadt@ some time ago.
-rw-r--r--main.c15
-rw-r--r--mandocdb.c19
2 files changed, 21 insertions, 13 deletions
diff --git a/main.c b/main.c
index 34666209..65659a44 100644
--- a/main.c
+++ b/main.c
@@ -299,8 +299,9 @@ main(int argc, char *argv[])
use_pager = 0;
#if HAVE_PLEDGE
- if (!use_pager && pledge("stdio rpath flock", NULL) == -1)
- err((int)MANDOCLEVEL_SYSERR, "pledge");
+ if (!use_pager)
+ if (pledge("stdio rpath flock", NULL) == -1)
+ err((int)MANDOCLEVEL_SYSERR, "pledge");
#endif
/* Parse arguments. */
@@ -430,9 +431,13 @@ main(int argc, char *argv[])
/* mandoc(1) */
#if HAVE_PLEDGE
- if (pledge(use_pager ? "stdio rpath tmppath tty proc exec" :
- "stdio rpath", NULL) == -1)
- err((int)MANDOCLEVEL_SYSERR, "pledge");
+ if (use_pager) {
+ if (pledge("stdio rpath tmppath tty proc exec", NULL) == -1)
+ err((int)MANDOCLEVEL_SYSERR, "pledge");
+ } else {
+ if (pledge("stdio rpath", NULL) == -1)
+ err((int)MANDOCLEVEL_SYSERR, "pledge");
+ }
#endif
if (search.argmode == ARG_FILE && ! moptions(&options, auxpaths))
diff --git a/mandocdb.c b/mandocdb.c
index 7d1c0555..58ebaa97 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -420,9 +420,11 @@ mandocdb(int argc, char *argv[])
argv += optind;
#if HAVE_PLEDGE
- if (nodb && pledge("stdio rpath", NULL) == -1) {
- perror("pledge");
- return (int)MANDOCLEVEL_SYSERR;
+ if (nodb) {
+ if (pledge("stdio rpath", NULL) == -1) {
+ perror("pledge");
+ return (int)MANDOCLEVEL_SYSERR;
+ }
}
#endif
@@ -452,11 +454,12 @@ mandocdb(int argc, char *argv[])
* all files specified on the command-line.
*/
#if HAVE_PLEDGE
- if (!nodb && pledge("stdio rpath wpath cpath fattr flock",
- NULL) == -1) {
- perror("pledge");
- exitcode = (int)MANDOCLEVEL_SYSERR;
- goto out;
+ if (!nodb) {
+ if (pledge("stdio rpath wpath cpath fattr flock", NULL) == -1) {
+ perror("pledge");
+ exitcode = (int)MANDOCLEVEL_SYSERR;
+ goto out;
+ }
}
#endif
use_all = 1;