source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: pledge(2) style: Make sure to always use the idiom 'if
Date: Tue, 15 Dec 2015 12:39:15 -0500 (EST)	[thread overview]
Message-ID: <8881979299862314231.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        main.c
        mandocdb.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.259
retrieving revision 1.260
diff -Lmain.c -Lmain.c -u -p -r1.259 -r1.260
--- main.c
+++ 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))
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.209 -r1.210
--- mandocdb.c
+++ 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;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-12-15 17:39 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=8881979299862314231.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.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).