source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: No point in trying to go on when elementary database operations
Date: Thu, 26 Nov 2015 02:42:41 -0500 (EST)	[thread overview]
Message-ID: <2363551566866265763.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
No point in trying to go on when elementary database operations
like preparing queries or binding variables fail; that won't yield
useful results anyway but may generate huge pointless error messages.
Issue reported by deraadt@.

Modified Files:
--------------
    mdocml:
        compat_err.c
        configure
        mansearch.c

Revision Data
-------------
Index: compat_err.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/compat_err.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lcompat_err.c -Lcompat_err.c -u -p -r1.3 -r1.4
--- compat_err.c
+++ compat_err.c
@@ -77,6 +77,18 @@ err(int eval, const char *fmt, ...)
 }
 
 void
+errx(int eval, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vwarnxi(fmt, ap);
+	va_end(ap);
+	fputc('\n', stderr);
+	exit(eval);
+}
+
+void
 warn(const char *fmt, ...)
 {
 	va_list ap;
Index: configure
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lconfigure -Lconfigure -u -p -r1.36 -r1.37
--- configure
+++ configure
@@ -339,6 +339,7 @@ __HEREDOC__
 
 if [ ${HAVE_ERR} -eq 0 ]; then
 	echo "extern	void	  err(int, const char *, ...);"
+	echo "extern	void	  errx(int, const char *, ...);"
 	echo "extern	void	  warn(const char *, ...);"
 	echo "extern	void	  warnx(const char *, ...);"
 fi
Index: mansearch.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mansearch.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Lmansearch.c -Lmansearch.c -u -p -r1.62 -r1.63
--- mansearch.c
+++ mansearch.c
@@ -54,17 +54,17 @@ extern const char *const mansearch_keyna
 #define	SQL_BIND_TEXT(_db, _s, _i, _v) \
 	do { if (SQLITE_OK != sqlite3_bind_text \
 		((_s), (_i)++, (_v), -1, SQLITE_STATIC)) \
-		warnx("%s", sqlite3_errmsg((_db))); \
+		errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
 	} while (0)
 #define	SQL_BIND_INT64(_db, _s, _i, _v) \
 	do { if (SQLITE_OK != sqlite3_bind_int64 \
 		((_s), (_i)++, (_v))) \
-		warnx("%s", sqlite3_errmsg((_db))); \
+		errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
 	} while (0)
 #define	SQL_BIND_BLOB(_db, _s, _i, _v) \
 	do { if (SQLITE_OK != sqlite3_bind_blob \
 		((_s), (_i)++, (&_v), sizeof(_v), SQLITE_STATIC)) \
-		warnx("%s", sqlite3_errmsg((_db))); \
+		errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
 	} while (0)
 
 struct	expr {
@@ -262,7 +262,8 @@ mansearch(const struct mansearch *search
 		j = 1;
 		c = sqlite3_prepare_v2(db, sql, -1, &s, NULL);
 		if (SQLITE_OK != c)
-			warnx("%s", sqlite3_errmsg(db));
+			errx((int)MANDOCLEVEL_SYSERR,
+			    "%s", sqlite3_errmsg(db));
 
 		for (ep = e; NULL != ep; ep = ep->next) {
 			if (NULL == ep->substr) {
@@ -312,14 +313,16 @@ mansearch(const struct mansearch *search
 		    "WHERE pageid=? ORDER BY sec, arch, name",
 		    -1, &s, NULL);
 		if (SQLITE_OK != c)
-			warnx("%s", sqlite3_errmsg(db));
+			errx((int)MANDOCLEVEL_SYSERR,
+			    "%s", sqlite3_errmsg(db));
 
 		c = sqlite3_prepare_v2(db,
 		    "SELECT bits, key, pageid FROM keys "
 		    "WHERE pageid=? AND bits & ?",
 		    -1, &s2, NULL);
 		if (SQLITE_OK != c)
-			warnx("%s", sqlite3_errmsg(db));
+			errx((int)MANDOCLEVEL_SYSERR,
+			    "%s", sqlite3_errmsg(db));
 
 		for (mp = ohash_first(&htab, &idx);
 				NULL != mp;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-11-26  7:42 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=2363551566866265763.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).