diff options
author | 2015-12-15 17:36:19 +0000 | |
---|---|---|
committer | 2015-12-15 17:36:19 +0000 | |
commit | 2571552d42a993dcc2b4d50f99b4e223c531b381 (patch) | |
tree | b9725470183851172166965394a9fcae2e1b0cf4 | |
parent | Revert the previous commit; the licencing needs to be checked very carefully. (diff) | |
download | wireguard-openbsd-2571552d42a993dcc2b4d50f99b4e223c531b381.tar.xz wireguard-openbsd-2571552d42a993dcc2b4d50f99b4e223c531b381.zip |
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-- | usr.bin/mandoc/main.c | 17 | ||||
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 21 |
2 files changed, 23 insertions, 15 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 37572a1c2ae..8e18c7a92ab 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.166 2015/11/20 21:58:32 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.167 2015/12/15 17:36:19 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -272,8 +272,9 @@ main(int argc, char *argv[]) !isatty(STDOUT_FILENO)) use_pager = 0; - 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"); /* Parse arguments. */ @@ -390,9 +391,13 @@ main(int argc, char *argv[]) /* mandoc(1) */ - 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"); + } if (search.argmode == ARG_FILE && ! moptions(&options, auxpaths)) return (int)MANDOCLEVEL_BADARG; diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index d811864373c..991070f0186 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mandocdb.c,v 1.162 2015/11/07 17:58:52 schwarze Exp $ */ +/* $OpenBSD: mandocdb.c,v 1.163 2015/12/15 17:36:19 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -409,9 +409,11 @@ mandocdb(int argc, char *argv[]) argc -= optind; argv += optind; - 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; + } } if (OP_CONFFILE == op && argc > 0) { @@ -439,11 +441,12 @@ mandocdb(int argc, char *argv[]) * The existing database is usable. Process * all files specified on the command-line. */ - 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; + } } use_all = 1; for (i = 0; i < argc; i++) |