diff options
| author | gutteridge <gutteridge@NetBSD.org> | 2022-04-06 03:23:38 +0000 |
|---|---|---|
| committer | gutteridge <gutteridge@NetBSD.org> | 2022-04-06 03:23:38 +0000 |
| commit | 5e2a5e1cc079f31a17f5143966751b4d1c688ddf (patch) | |
| tree | cdde3a9b84b68d19cc3de564391982c2acb87c1e /usr.sbin/makemandb | |
| parent | 80ab99cc83356019516b7293b3c7d41402ed6f17 (diff) | |
makemandb.c: fail sooner if man page dirs can't be found
There's no point initializing database state if we're then going to
fail to locate any man page sources. Make all the initial state checks
contiguous for simplicity and readability. Also, free the variable
"command" on the error path, and correct the error message.
Diffstat (limited to 'usr.sbin/makemandb')
| -rw-r--r-- | usr.sbin/makemandb/makemandb.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.sbin/makemandb/makemandb.c b/usr.sbin/makemandb/makemandb.c index 82c8799d587..c7065ad3a7e 100644 --- a/usr.sbin/makemandb/makemandb.c +++ b/usr.sbin/makemandb/makemandb.c @@ -1,4 +1,4 @@ -/* $NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $ */ +/* $NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $ */ /* * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $"); +__RCSID("$NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $"); #include <sys/stat.h> #include <sys/types.h> @@ -351,6 +351,13 @@ main(int argc, char *argv[]) manconf = MANCONF; } + /* Call man -p to get the list of man page dirs */ + if ((file = popen(command, "r")) == NULL) { + free(command); + err(EXIT_FAILURE, "popen failed"); + } + free(command); + if (mflags.recreate) { char *dbp = get_dbpath(manconf); /* No error here, it will fail in init_db in the same call */ @@ -378,14 +385,6 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - - /* Call man -p to get the list of man page dirs */ - if ((file = popen(command, "r")) == NULL) { - close_db(db); - err(EXIT_FAILURE, "fopen failed"); - } - free(command); - /* Begin the transaction for indexing the pages */ sqlite3_exec(db, "BEGIN", NULL, NULL, &errmsg); if (errmsg != NULL) { |
