source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: * Fix the return value from main().
Date: Fri, 22 Mar 2019 13:02:37 -0500 (EST)	[thread overview]
Message-ID: <e3fc943b21e56147@fantadrom.bsd.lv> (raw)

Log Message:
-----------
* Fix the return value from main().
* Do not use the pointless constants EXIT_SUCCESS and EXIT_FAILURE.
* KNF: remove parentheses from return statements.

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c

Revision Data
-------------
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.62 -r1.63
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -268,7 +268,7 @@ xml_char(void *arg, const XML_Char *p, i
 		dat = calloc(1, sizeof(struct pnode));
 		if (NULL == dat) {
 			perror(NULL);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 
 		dat->node = ps->node = NODE_TEXT;
@@ -286,7 +286,7 @@ xml_char(void *arg, const XML_Char *p, i
 		ps->cur->bsz + (size_t)sz);
 	if (NULL == ps->cur->b) {
 		perror(NULL);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 	memcpy(ps->cur->b + ps->cur->bsz, p, sz);
 	ps->cur->bsz += (size_t)sz;
@@ -366,7 +366,7 @@ xml_elem_start(void *arg, const XML_Char
 
 	if (NULL == (dat = calloc(1, sizeof(struct pnode)))) {
 		perror(NULL);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	dat->node = ps->node = node->node;
@@ -504,7 +504,7 @@ pnode_getattr(struct pnode *pn, enum att
 	TAILQ_FOREACH(ap, &pn->attrq, child)
 		if (ap->key == key)
 			return ap->val;
-	return(ATTRVAL__MAX);
+	return ATTRVAL__MAX;
 }
 
 /*
@@ -520,7 +520,7 @@ pnode_getattr_raw(struct pnode *pn, enum
 		if (ap->key == key)
 			return ATTRVAL__MAX == ap->val ? ap->rawval :
 			    attrvals[ap->val];
-	return(defval);
+	return defval;
 }
 
 /*
@@ -547,7 +547,7 @@ bufappend(struct parse *p, struct pnode 
 		p->mbsz = p->bsz + pn->bsz + 1;
 		if (NULL == (p->b = realloc(p->b, p->mbsz))) {
 			perror(NULL);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 	memcpy(p->b + p->bsz, pn->b, pn->bsz);
@@ -588,7 +588,7 @@ pnode_findfirst(struct pnode *pn, enum n
 			break;
 	}
 
-	return(res);
+	return res;
 }
 
 #define MACROLINE_NORM	0
@@ -1719,14 +1719,14 @@ readfile(XML_Parser xp, int fd,
 		pnode_print(&p, p.root);
 		pnode_free(p.root);
 		free(p.b);
-		return(0 != rc && ! p.stop);
+		return rc != 0 && p.stop == 0;
 	}
 
 	/* Read error has occured. */
 	perror(fn);
 	pnode_free(p.root);
 	free(p.b);
-	return(0);
+	return 0;
 }
 
 int
@@ -1747,7 +1747,7 @@ main(int argc, char *argv[])
 	fname = "-";
 	xp = NULL;
 	buf = NULL;
-	rc = 0;
+	rc = 1;
 
 	while (-1 != (ch = getopt(argc, argv, "W")))
 		switch (ch) {
@@ -1783,16 +1783,16 @@ main(int argc, char *argv[])
 		perror(NULL);
 	else if (NULL == (xp = XML_ParserCreate(NULL)))
 		perror(NULL);
-	else if ( ! readfile(xp, fd, buf, 4096, fname))
-		rc = 1;
+	else if (readfile(xp, fd, buf, 4096, fname))
+		rc = 0;
 
 	XML_ParserFree(xp);
 	free(buf);
 	if (STDIN_FILENO != fd)
 		close(fd);
-	return(rc ? EXIT_SUCCESS : EXIT_FAILURE);
+	return rc;
 
 usage:
 	fprintf(stderr, "usage: %s [-W] [input_filename]\n", progname);
-	return(EXIT_FAILURE);
+	return 1;
 }
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2019-03-22 18:02 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=e3fc943b21e56147@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).