Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb Remove the table name parameter from the ...



details:   https://anonhg.NetBSD.org/src/rev/a58358bfbfa8
branches:  trunk
changeset: 823657:a58358bfbfa8
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Mon May 01 06:43:56 2017 +0000

description:
Remove the table name parameter from the check_md5 function.

There is only one table storing the md5 checksums, so we can hardcode the table
name instead of passing it as a function argument.

diffstat:

 usr.sbin/makemandb/makemandb.c |  17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diffs (66 lines):

diff -r 96305ba681b7 -r a58358bfbfa8 usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Mon May 01 05:52:33 2017 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Mon May 01 06:43:56 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $   */
+/*     $NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $   */
 /*
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -96,7 +96,7 @@
 static void append(secbuff *sbuff, const char *src);
 static void init_secbuffs(mandb_rec *);
 static void free_secbuffs(mandb_rec *);
-static int check_md5(const char *, sqlite3 *, const char *, char **, void *, size_t);
+static int check_md5(const char *, sqlite3 *, char **, void *, size_t);
 static void cleanup(mandb_rec *);
 static void set_section(const struct roff_man *, mandb_rec *);
 static void set_machine(const struct roff_man *, mandb_rec *);
@@ -804,8 +804,7 @@
                        err_count++;
                        continue;
                }
-               md5_status = check_md5(file, db, "mandb_meta", &md5sum, buf,
-                   buflen);
+               md5_status = check_md5(file, db, &md5sum, buf, buflen);
                assert(md5sum != NULL);
                if (md5_status == -1) {
                        if (mflags.verbosity)
@@ -1822,7 +1821,7 @@
 /*
  * check_md5--
  *  Generates the md5 hash of the file and checks if it already doesn't exist
- *  in the table (passed as the 3rd parameter).
+ *  in the table.
  *  This function is being used to avoid hardlinks.
  *  On successful completion it will also set the value of the fourth parameter
  *  to the md5 hash of the file (computed previously). It is the responsibility
@@ -1833,8 +1832,7 @@
  *  1: If the hash exists in the database.
  */
 static int
-check_md5(const char *file, sqlite3 *db, const char *table, char **md5sum,
-    void *buf, size_t buflen)
+check_md5(const char *file, sqlite3 *db, char **md5sum, void *buf, size_t buflen)
 {
        int rc = 0;
        int idx = -1;
@@ -1849,8 +1847,7 @@
                return -1;
        }
 
-       easprintf(&sqlstr, "SELECT * FROM %s WHERE md5_hash = :md5_hash",
-           table);
+       easprintf(&sqlstr, "SELECT * FROM mandb_meta WHERE md5_hash = :md5_hash");
        rc = sqlite3_prepare_v2(db, sqlstr, -1, &stmt, NULL);
        if (rc != SQLITE_OK) {
                free(sqlstr);



Home | Main Index | Thread Index | Old Index