summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-05-29 15:03:35 +0000
committerjbj <devnull@localhost>2001-05-29 15:03:35 +0000
commit61cd63ab8e816d46e81b3df2bb8cfe9b2267f85d (patch)
tree435a2ee8e9fdf33d9af2f4188dd9e100ac36e1e4
parente6c22123bc088afd6f0f564b8f5224af3cf2d2e6 (diff)
downloadrpm-61cd63ab8e816d46e81b3df2bb8cfe9b2267f85d.tar.gz
rpm-61cd63ab8e816d46e81b3df2bb8cfe9b2267f85d.tar.bz2
rpm-61cd63ab8e816d46e81b3df2bb8cfe9b2267f85d.zip
- eliminate db-1.85 and db-2.x configuration.
- fix: popt arg sanity checks broken, optarg != optArg. - fix: popt range checks on floats/doubles broken. - popt: return POPT_ERROR_ERRNO on config open/read/close failure. CVS patchset: 4815 CVS date: 2001/05/29 15:03:35
-rw-r--r--CHANGES4
-rw-r--r--Doxyfile.in1
-rw-r--r--configure.in51
-rw-r--r--gendiff2
-rw-r--r--perl/Makefile.in2
-rw-r--r--po/POTFILES.in1
-rw-r--r--popt/popt.c116
-rw-r--r--popt/poptconfig.c20
-rw-r--r--python/Makefile.in2
-rw-r--r--rpmdb/.cvsignore1
-rw-r--r--rpmdb/Makefile.am4
-rw-r--r--rpmdb/db1.c115
-rw-r--r--rpmdb/db2.c893
-rw-r--r--rpmdb/db3.c7
-rw-r--r--rpmdb/rpmdb.c1
-rw-r--r--rpmdb/rpmdb.h7
-rwxr-xr-xrpmqv.c37
17 files changed, 182 insertions, 1082 deletions
diff --git a/CHANGES b/CHANGES
index e299ab86a..d92027cfe 100644
--- a/CHANGES
+++ b/CHANGES
@@ -64,6 +64,10 @@
- headerFree() returns NULL, _free is C++ safe.
- remove all header region assertion failures, return NULL instead.
- perform db->verify when closing db files.
+ - eliminate db-1.85 and db-2.x configuration.
+ - fix: popt arg sanity checks broken, optarg != optArg.
+ - fix: popt range checks on floats/doubles broken.
+ - popt: return POPT_ERROR_ERRNO on config open/read/close failure.
4.0 -> 4.0.[12]
- add doxygen and lclint annotations most everywhere.
diff --git a/Doxyfile.in b/Doxyfile.in
index 8240872c5..fcbfe7860 100644
--- a/Doxyfile.in
+++ b/Doxyfile.in
@@ -391,7 +391,6 @@ INPUT = \
./lib/transaction.c \
./lib/verify.c \
./rpmdb/db1.c \
- ./rpmdb/db2.c \
./rpmdb/db3.c \
./rpmdb/dbconfig.c \
./rpmdb/falloc.c \
diff --git a/configure.in b/configure.in
index 99493c232..17e233973 100644
--- a/configure.in
+++ b/configure.in
@@ -330,8 +330,6 @@ WITH_INTERNAL_DB=0
DBLIBSRCS=""
libdb3=""
libdb3a=""
-libdb2=""
-libdb1=""
dnl
dnl Detect whether internal Berkeley DB should be built.
@@ -342,7 +340,7 @@ AC_ARG_WITH(db, [ --without-db do not use internal Berkeley db])
if test $withval = no ; then
dnl ------------------ without internal db
-AC_CHECK_HEADERS(db_185.h db1/db.h db3/db.h)
+AC_CHECK_HEADERS(db3/db.h)
dnl Check for Berkeley db3 API.
AC_CHECK_FUNC(db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"],
@@ -356,36 +354,6 @@ AC_CHECK_FUNC(db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"],
,$libthread)
)
-dnl Check for Berkeley db2 API.
-dnl AC_CHECK_FUNC(db_open, [DBLIBSRCS="$DBLIBSRCS db2.c"],
-dnl AC_CHECK_LIB(db2, db_open, [LIBS="$LIBS"; DBLIBSRCS="$DBLIBSRCS db2.c" ; libdb2="-ldb2"],
-dnl AC_CHECK_LIB(db, db_open, [LIBS="$LIBS"; DBLIBSRCS="$DBLIBSRCS db2.c" ; libdb2="-ldb"],
-dnl )
-dnl )
-dnl )
-
-dnl Check for Berkeley db1 API retrofit to db2/db3 database.
-dnl AC_CHECK_FUNC(dbopen, [DBLIBSRCS="$DBLIBSRCS db1.c falloc.c"],
-dnl AC_CHECK_LIB(db, dbopen, [DBLIBSRCS="$DBLIBSRCS db1.c falloc.c"])
-dnl )
-
-AC_MSG_CHECKING(whether to enable DB1 support)
-
-AC_ARG_ENABLE(db1,
-[ --enable-db1 Enable DB1 support ],
-[
-if test "$enableval" = "no"; then
- AC_MSG_RESULT(no)
- usedb1=no
-else
- AC_MSG_RESULT(yes)
- usedb1=yes
-fi
-],[
-AC_MSG_RESULT(no)
-usedb1=no
-])
-
if test X"$DBLIBSRCS" = X; then
AC_MSG_ERROR([sorry rpm requires libdb-3.x.a (from the Berkeley db package)])
fi
@@ -405,37 +373,25 @@ dnl ------------------ with internal db
WITH_DB_SUBDIR=db3
WITH_INTERNAL_DB=1
DBLIBSRCS="db3.c"
- usedb1=no
libdb3="# \$(top_builddir)/db3/libdb.la"
libdb3a="\$(top_builddir)/db3/libdb.a"
dnl INCPATH="-I\$(top_builddir)/$(WITH_DB_SUBDIR) $INCPATH"
fi
-if test "$usedb1" = "yes"; then
- dnl Check for Berkeley db1 API in glibc.
- AC_CHECK_FUNC(dbopen, [DBLIBSRCS="$DBLIBSRCS db3.c"],
- AC_CHECK_LIB(db1, dbopen, [DBLIBSRCS="$DBLIBSRCS db1.c falloc.c" ; libdb1="-ldb1"],
- AC_CHECK_LIB(db, dbopen, [DBLIBSRCS="$DBLIBSRCS db1.c falloc.c" ; libdb1="-ldb"])
- )
- )
-fi
-
AC_SUBST(WITH_DB_SUBDIR)
AC_SUBST(WITH_INTERNAL_DB)
+DBLIBSRCS="$DBLIBSRCS db1.c falloc.c"
DBLIBOBJS=`echo $DBLIBSRCS | sed -e "s/\.c/\.lo/g"`
AC_SUBST(DBLIBSRCS)
AC_SUBST(DBLIBOBJS)
AC_SUBST(libdb3)
AC_SUBST(libdb3a)
-AC_SUBST(libdb2)
-AC_SUBST(libdb1)
for dbi in $DBLIBSRCS; do
case $dbi in
db3.c) AC_DEFINE(USE_DB3) ;;
- db2.c) AC_DEFINE(USE_DB2) ;;
db1.c) AC_DEFINE(USE_DB1) ;;
esac
done
@@ -1043,9 +999,10 @@ sparc*) RPMCANONARCH=sparc ;;
ia64*) RPMCANONARCH=ia64 ;;
s390*) RPMCANONARCH=s390 ;;
powerpc*) RPMCANONARCH=ppc ;;
+armv3l*) RPMCANONARCH=armv3l ;;
armv4l*) RPMCANONARCH=armv4l ;;
armv4b*) RPMCANONARCH=armv4b ;;
-arm*) RPMCANONARCH=arm ;;
+arm*) RPMCANONARCH="${build_cpu}" ;;
m68k*) RPMCANONARCH=m68k ;;
*) RPMCANONARCH=unknown ;;
esac
diff --git a/gendiff b/gendiff
index 1a153b795..a90f6e4a3 100644
--- a/gendiff
+++ b/gendiff
@@ -9,6 +9,6 @@
find $1 \( -name "*$2" -o -name ".*$2" \) -print |
while read f; do
U=-u
- [ "${f##*/}" == "ChangeLog$2" ] && U=-U0
+ [ "${f##*/}" = "ChangeLog$2" ] && U=-U0
diff ${U} $f `echo $f | sed s/$2\$//`
done
diff --git a/perl/Makefile.in b/perl/Makefile.in
index a46fcc9e6..96b65be32 100644
--- a/perl/Makefile.in
+++ b/perl/Makefile.in
@@ -170,8 +170,6 @@ __SSH = @__SSH@
__STRIP = @__STRIP@
__TAR = @__TAR@
l = @l@
-libdb1 = @libdb1@
-libdb2 = @libdb2@
libdb3 = @libdb3@
libdb3a = @libdb3a@
testdir = @testdir@
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 970816419..826e08a10 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -49,7 +49,6 @@ lib/stringbuf.c
lib/transaction.c
lib/verify.c
rpmdb/db1.c
-rpmdb/db2.c
rpmdb/db3.c
rpmdb/dbconfig.c
rpmdb/falloc.c
diff --git a/popt/popt.c b/popt/popt.c
index 169c3a4f4..caae8b255 100644
--- a/popt/popt.c
+++ b/popt/popt.c
@@ -30,6 +30,20 @@ static char * strerror(int errno) {
}
#endif
+#ifdef MYDEBUG
+/*@unused@*/ static void prtcon(const char *msg, poptContext con)
+{
+ if (msg) fprintf(stderr, "%s", msg);
+ fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n",
+ con, con->os,
+ (con->os->nextCharArg ? con->os->nextCharArg : ""),
+ (con->os->nextArg ? con->os->nextArg : ""),
+ con->os->next,
+ (con->os->argv && con->os->argv[con->os->next]
+ ? con->os->argv[con->os->next] : ""));
+}
+#endif
+
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
{
con->execPath = _free(con->execPath);
@@ -105,9 +119,10 @@ static void invokeCallbacksOPTION(poptContext con,
/*@=castfcnptr@*/
const void * cbData = (cbopt->descrip ? cbopt->descrip : myData);
/* Perform callback. */
- if (cb != NULL) /* XXX program error */
+ if (cb != NULL) { /* XXX program error */
cb(con, POPT_CALLBACK_REASON_OPTION, myOpt,
con->os->nextArg, cbData);
+ }
/* Terminate (unless explcitly continuing). */
if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE))
return;
@@ -150,10 +165,10 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
con->flags |= POPT_CONTEXT_POSIXMEHARDER;
- if (name)
- /*@-nullpass@*/ /* FIX: malloc can return NULL. */
- con->appName = strcpy(malloc(strlen(name) + 1), name);
- /*@=nullpass@*/
+ if (name) {
+ char * t = malloc(strlen(name) + 1);
+ if (t) con->appName = strcpy(t, name);
+ }
invokeCallbacksPRE(con, con->options);
@@ -349,7 +364,7 @@ static int execCommand(poptContext con)
argc += con->numLeftovers;
}
- argv[argc++] = NULL;
+ argv[argc] = NULL;
#ifdef __hpux
(void) setresuid(getuid(), getuid(),-1);
@@ -371,10 +386,10 @@ static int execCommand(poptContext con)
if (argv[0] == NULL)
return POPT_ERROR_NOARG;
#ifdef MYDEBUG
- { const char ** arg;
- fprintf(stderr, "==> execvp(%s):", argv[0]);
- for (arg = argv; *arg; arg++)
- fprintf(stderr, " %s", *arg);
+ { const char ** avp;
+ fprintf(stderr, "==> execvp(%s) argv[%d]:", argv[0], argc);
+ for (avp = argv; *avp; avp++)
+ fprintf(stderr, " '%s'", *avp);
fprintf(stderr, "\n");
}
#endif
@@ -401,21 +416,19 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
const struct poptOption * opt2;
+
/* Recurse on included sub-tables. */
if (opt->arg == NULL) continue; /* XXX program error */
opt2 = findOption(opt->arg, longName, shortName, callback,
callbackData, singleDash);
- if (opt2) {
- /* Sub-table data will be inheirited if no data yet. */
- /*@-nullderef@*/ /* LCL: *callback != NULL */
- if (callback && *callback &&
- callbackData && *callbackData == NULL)
- /*@-observertrans -dependenttrans @*/
- *callbackData = opt->descrip;
- /*@=observertrans =dependenttrans @*/
- /*@=nullderef@*/
- return opt2;
- }
+ if (opt2 == NULL) continue;
+ /* Sub-table data will be inheirited if no data yet. */
+ if (!(callback && *callback)) return opt2;
+ if (!(callbackData && *callback == NULL)) return opt2;
+ /*@-observertrans -dependenttrans @*/
+ *callbackData = opt->descrip;
+ /*@=observertrans =dependenttrans @*/
+ return opt2;
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) {
cb = opt;
} else if (longName && opt->longName &&
@@ -589,20 +602,6 @@ static int poptSaveInt(const struct poptOption * opt, long aLong)
return 0;
}
-#ifdef MYDEBUG
-static void prtcon(const char *msg, poptContext con)
-{
- if (msg) fprintf(stderr, "%s", msg);
- fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n",
- con, con->os,
- (con->os->nextCharArg ? con->os->nextCharArg : ""),
- (con->os->nextArg ? con->os->nextArg : ""),
- con->os->next,
- (con->os->argv && con->os->argv[con->os->next]
- ? con->os->argv[con->os->next] : ""));
-}
-#endif
-
/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
int poptGetNextOpt(poptContext con)
{
@@ -698,7 +697,8 @@ int poptGetNextOpt(poptContext con)
con->os->nextCharArg = origOptString + 1;
} else {
if (con->os == con->optionStack &&
- opt->argInfo & POPT_ARGFLAG_STRIP) {
+ opt->argInfo & POPT_ARGFLAG_STRIP)
+ {
canstrip = 1;
poptStripArg(con, thisopt);
}
@@ -751,13 +751,11 @@ int poptGetNextOpt(poptContext con)
/*@-usedef@*/ /* FIX: W2DO? */
if (longArg) {
/*@=usedef@*/
- /*@-evalorder@*/ /* FIX: W2DO? */
- con->os->nextArg = expandNextArg(con, longArg);
- /*@=evalorder@*/
+ longArg = expandNextArg(con, longArg);
+ con->os->nextArg = longArg;
} else if (con->os->nextCharArg) {
- /*@-evalorder@*/ /* FIX: W2DO? */
- con->os->nextArg = expandNextArg(con, con->os->nextCharArg);
- /*@=evalorder@*/
+ longArg = expandNextArg(con, con->os->nextCharArg);
+ con->os->nextArg = longArg;
con->os->nextCharArg = NULL;
} else {
while (con->os->next == con->os->argc &&
@@ -774,18 +772,20 @@ int poptGetNextOpt(poptContext con)
/* make sure this isn't part of a short arg or the
result of an alias expansion */
if (con->os == con->optionStack &&
- opt->argInfo & POPT_ARGFLAG_STRIP &&
+ (opt->argInfo & POPT_ARGFLAG_STRIP) &&
canstrip) {
poptStripArg(con, con->os->next);
}
- if (con->os->argv != NULL) /* XXX can't happen */
- /*@-evalorder@*/ /* FIX: W2DO? */
- con->os->nextArg =
- expandNextArg(con, con->os->argv[con->os->next++]);
- /*@=evalorder@*/
+ if (con->os->argv != NULL) { /* XXX can't happen */
+ longArg =
+ expandNextArg(con, con->os->argv[con->os->next]);
+ con->os->nextArg = longArg;
+ con->os->next++;
+ }
}
}
+ longArg = NULL;
if (opt->arg) {
switch (opt->argInfo & POPT_ARG_MASK) {
@@ -825,29 +825,31 @@ int poptGetNextOpt(poptContext con)
char *end;
if (con->os->nextArg) {
+ int saveerrno = errno;
+ errno = 0;
aDouble = strtod(con->os->nextArg, &end);
+ if (errno == ERANGE)
+ return POPT_ERROR_OVERFLOW;
+ errno = saveerrno;
if (*end != '\0')
return POPT_ERROR_BADNUMBER;
}
- if ((aDouble - HUGE_VAL) < DBL_EPSILON ||
- (aDouble + HUGE_VAL) < DBL_EPSILON)
- return POPT_ERROR_OVERFLOW;
- if ((aDouble - 0.0) < DBL_EPSILON && errno == ERANGE)
- return POPT_ERROR_OVERFLOW;
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) {
*((double *) opt->arg) = aDouble;
} else {
- if ((aDouble - FLT_MAX) > DBL_EPSILON)
+#define _ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
+ if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
return POPT_ERROR_OVERFLOW;
- if ((aDouble + FLT_MIN) > DBL_EPSILON)
+ if ((FLT_MIN - _ABS(aDouble)) > DBL_EPSILON)
return POPT_ERROR_OVERFLOW;
*((float *) opt->arg) = aDouble;
}
} break;
default:
- fprintf(stdout, POPT_("option type (%d) not implemented in popt\n"),
- opt->argInfo & POPT_ARG_MASK);
+ fprintf(stdout,
+ POPT_("option type (%d) not implemented in popt\n"),
+ (opt->argInfo & POPT_ARG_MASK));
exit(EXIT_FAILURE);
}
}
diff --git a/popt/poptconfig.c b/popt/poptconfig.c
index d5186468b..f53dd5d37 100644
--- a/popt/poptconfig.c
+++ b/popt/poptconfig.c
@@ -70,18 +70,19 @@ int poptReadConfigFile(poptContext con, const char * fn)
char * buf;
/*@dependent@*/ char * dst;
int fd, rc;
- int fileLength;
+ off_t fileLength;
fd = open(fn, O_RDONLY);
- if (fd < 0) {
- if (errno == ENOENT)
- return 0;
- else
- return POPT_ERROR_ERRNO;
- }
+ if (fd < 0)
+ return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
fileLength = lseek(fd, 0, SEEK_END);
- (void) lseek(fd, 0, 0);
+ if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
+ rc = errno;
+ (void) close(fd);
+ errno = rc;
+ return POPT_ERROR_ERRNO;
+ }
file = alloca(fileLength + 1);
if (read(fd, (char *)file, fileLength) != fileLength) {
@@ -90,7 +91,8 @@ int poptReadConfigFile(poptContext con, const char * fn)
errno = rc;
return POPT_ERROR_ERRNO;
}
- (void) close(fd);
+ if (close(fd) == -1)
+ return POPT_ERROR_ERRNO;
dst = buf = alloca(fileLength + 1);
diff --git a/python/Makefile.in b/python/Makefile.in
index d883cac3b..90cd1ec91 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -170,8 +170,6 @@ __SSH = @__SSH@
__STRIP = @__STRIP@
__TAR = @__TAR@
l = @l@
-libdb1 = @libdb1@
-libdb2 = @libdb2@
libdb3 = @libdb3@
libdb3a = @libdb3a@
testdir = @testdir@
diff --git a/rpmdb/.cvsignore b/rpmdb/.cvsignore
index dcf4befde..cd6022767 100644
--- a/rpmdb/.cvsignore
+++ b/rpmdb/.cvsignore
@@ -3,5 +3,6 @@
Makefile
Makefile.in
.libs
+db3lobjs
*.la
*.lo
diff --git a/rpmdb/Makefile.am b/rpmdb/Makefile.am
index 43422a8f9..0e4a71295 100644
--- a/rpmdb/Makefile.am
+++ b/rpmdb/Makefile.am
@@ -10,7 +10,7 @@ INCLUDES = \
-I$(top_srcdir)/popt \
@INCPATH@
-EXTRA_DIST = db3.c db2.c db1.c falloc.c
+EXTRA_DIST = db3.c db1.c falloc.c
pkgincdir = $(pkgincludedir)
pkginc_HEADERS = rpmdb.h
@@ -28,7 +28,7 @@ DB3LOBJS = $(shell cat $(top_builddir)/$(WITH_DB_SUBDIR)/db3lobjs)
lib_LTLIBRARIES = librpmdb.la
librpmdb_la_SOURCES = $(DBLIBSRCS) dbconfig.c fprint.c rpmhash.c rpmdb.c
-librpmdb_la_LDFLAGS = @libdb3@ @libdb2@ @libdb1@
+librpmdb_la_LDFLAGS = @libdb3@
librpmdb_la_LIBADD = $(DBLIBOBJS) $(DB3LOBJS)
librpmdb_la_DEPENDENCIES = $(DBLIBOBJS) createlinks
diff --git a/rpmdb/db1.c b/rpmdb/db1.c
index 1af5f2f9d..b016f854e 100644
--- a/rpmdb/db1.c
+++ b/rpmdb/db1.c
@@ -4,21 +4,7 @@
#include "system.h"
-static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
-
-#ifdef HAVE_DB1_DB_H
-#include <db1/db.h>
-#else
-#ifdef HAVE_DB_185_H
-#include <db_185.h> /* XXX there are too mant compat API's for this to work */
-#else
-#include <db.h>
-#endif
-#endif
-
-#define DB_VERSION_MAJOR 1
-#define DB_VERSION_MINOR 85
-#define DB_VERSION_PATCH 0
+/*@unused@*/ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#define _mymemset(_a, _b, _c)
@@ -30,9 +16,21 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#include "falloc.h"
#include "misc.h"
-#define DBC void
#include "rpmdb.h"
+/* XXX must follow rpmdb.h */
+#define DB_VERSION_MAJOR 1
+#define DB_VERSION_MINOR 85
+#define DB_VERSION_PATCH 0
+
+struct _DBT1 {
+ void * data; /* data */
+ size_t size; /* data length */
+};
+
+#undef DBT
+#define DBT struct _DBT1
+
#include "debug.h"
/*@access Header@*/ /* XXX compared with NULL */
@@ -41,6 +39,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
/*@access dbiIndexSet@*/
/*@-onlytrans@*/
+#ifdef DYING
/* XXX remap DB3 types back into DB1 types */
static inline DBTYPE db3_to_dbtype(int dbitype)
{
@@ -105,8 +104,9 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
return rc;
}
+#endif /* DYING */
-static int db1sync(dbiIndex dbi, unsigned int flags) {
+static int db1sync(dbiIndex dbi, /*@unused@*/ unsigned int flags) {
int rc = 0;
if (dbi->dbi_db) {
@@ -115,17 +115,20 @@ static int db1sync(dbiIndex dbi, unsigned int flags) {
int fdno = Fileno(pkgs);
if (fdno >= 0 && (rc = fsync(fdno)) != 0)
rc = errno;
- } else {
+ }
+#ifdef DYING
+ else {
DB * db = dbi->dbi_db;
rc = db->sync(db, flags);
rc = cvtdberr(dbi, "db->sync", rc, _debug);
}
+#endif
}
return rc;
}
-static void * doGetRecord(FD_t pkgs, unsigned int offset)
+/*@null@*/ static void * doGetRecord(FD_t pkgs, unsigned int offset)
{
void * uh = NULL;
Header h = NULL;
@@ -141,13 +144,12 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
h = headerRead(pkgs, HEADER_MAGIC_NO);
/* let's sanity check this record a bit, otherwise just skip it */
- if (!(headerIsEntry(h, RPMTAG_NAME) &&
- headerIsEntry(h, RPMTAG_VERSION) &&
- headerIsEntry(h, RPMTAG_RELEASE) &&
- headerIsEntry(h, RPMTAG_BUILDTIME)))
+ if (!( headerIsEntry(h, RPMTAG_NAME) &&
+ headerIsEntry(h, RPMTAG_VERSION) &&
+ headerIsEntry(h, RPMTAG_RELEASE) &&
+ headerIsEntry(h, RPMTAG_BUILDTIME)))
{
- headerFree(h);
- h = NULL;
+ h = headerFree(h);
}
if (h == NULL)
@@ -204,7 +206,7 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
exit:
if (h != NULL) {
uh = headerUnload(h);
- headerFree(h);
+ h = headerFree(h);
}
return uh;
}
@@ -280,7 +282,9 @@ if (keylen) *keylen = key.size;
rc = EFAULT;
}
}
- } else {
+ }
+#ifdef DYING
+ else {
DB * db;
int _printit;
@@ -297,6 +301,10 @@ if (keylen) *keylen = key.size;
rc = cvtdberr(dbi, "db1cget", rc, _printit);
}
}
+#else
+ else
+ rc = EINVAL;
+#endif
if (rc == 0) {
if (keyp) *keyp = key.data;
@@ -314,28 +322,31 @@ if (keylen) *keylen = key.size;
static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp,
size_t keylen, /*@unused@*/ unsigned int flags)
{
+ DBT key;
int rc = 0;
+ memset(&key, 0, sizeof(key));
+ key.data = (void *)keyp;
+ key.size = keylen;
+
if (dbi->dbi_rpmtag == RPMDBI_PACKAGES) {
FD_t pkgs = dbi->dbi_db;
unsigned int offset;
memcpy(&offset, keyp, sizeof(offset));
fadFree(pkgs, offset);
- } else {
- DBT key;
+ }
+#ifdef DYING
+ else {
DB * db = dbi->dbi_db;
- _mymemset(&key, 0, sizeof(key));
-
- /*@-usedef@*/
- key.data = (void *)keyp;
- /*@=usedef@*/
- key.size = keylen;
-
if (db)
rc = db->del(db, &key, 0);
rc = cvtdberr(dbi, "db->del", rc, _debug);
}
+#else
+ else
+ rc = EINVAL;
+#endif
return rc;
}
@@ -375,21 +386,27 @@ static int db1cput(dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
fdSetContentLength(pkgs, -1);
if (rc)
rc = EIO;
- headerFree(h);
+ h = headerFree(h);
}
- } else {
+ }
+#ifdef DYING
+ else {
DB * db = dbi->dbi_db;
if (db)
rc = db->put(db, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
}
+#else
+ else
+ rc = EINVAL;
+#endif
return rc;
}
-static int db1ccount(dbiIndex dbi, DBC * dbcursor,
- /*@out@*/ unsigned int * countp,
+static int db1ccount(/*@unused@*/ dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
+ /*@unused@*/ /*@out@*/ unsigned int * countp,
/*@unused@*/ unsigned int flags)
{
return EINVAL;
@@ -400,7 +417,7 @@ static int db1byteswapped(/*@unused@*/dbiIndex dbi)
return 0;
}
-static int db1stat(dbiIndex dbi, unsigned int flags)
+static int db1stat(/*@unused@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
{
return EINVAL;
}
@@ -419,11 +436,17 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
if (dbi->dbi_rpmtag == RPMDBI_PACKAGES) {
FD_t pkgs = dbi->dbi_db;
rc = Fclose(pkgs);
- } else {
+ }
+#ifdef DYING
+ else {
DB * db = dbi->dbi_db;
rc = db->close(db);
rc = cvtdberr(dbi, "db->close", rc, _debug);
}
+#else
+ else
+ rc = EINVAL;
+#endif
dbi->dbi_db = NULL;
}
@@ -496,7 +519,9 @@ static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
}
dbi->dbi_db = pkgs;
- } else {
+ }
+#ifdef DYING
+ else {
void * dbopeninfo = NULL;
int dbimode = dbi->dbi_mode;
@@ -507,6 +532,10 @@ static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
db3_to_dbtype(dbi->dbi_type), dbopeninfo);
if (dbi->dbi_db == NULL) rc = errno;
}
+#else
+ else
+ rc = EINVAL;
+#endif
exit:
if (rc == 0 && dbi->dbi_db != NULL && dbip) {
diff --git a/rpmdb/db2.c b/rpmdb/db2.c
deleted file mode 100644
index af6d74f4f..000000000
--- a/rpmdb/db2.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/** \ingroup db2
- * \file rpmdb/db2.c
- */
-
-static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
-
-#ifdef __LCLINT__
-typedef unsigned int u_int32_t;
-typedef unsigned short u_int16_t;
-typedef unsigned char u_int8_t;
-typedef int int32_t;
-#endif
-
-#define INLINE
-
-#include "system.h"
-
-#include <db2/db.h>
-
-#include <rpmlib.h>
-#include <rpmmacro.h>
-#include <rpmurl.h> /* XXX urlPath proto */
-
-#include "rpmdb.h"
-#include "debug.h"
-
-/*@access rpmdb@*/
-/*@access dbiIndex@*/
-/*@access dbiIndexSet@*/
-
-#if DB_VERSION_MAJOR == 2
-#define __USE_DB2 1
-
-/* XXX remap DB3 types back into DB2 types */
-static INLINE DBTYPE db3_to_dbtype(int dbitype)
-{
- switch(dbitype) {
- case 1: return DB_BTREE;
- case 2: return DB_HASH;
- case 3: return DB_RECNO;
- case 4: return DB_HASH; /* XXX W2DO? */
- case 5: return DB_HASH; /* XXX W2DO? */
- }
- /*@notreached@*/ return DB_HASH;
-}
-
-#if defined(__USE_DB2) || defined(__USE_DB3)
-#if defined(__USE_DB2)
-static /*@observer@*/ const char * db_strerror(int error)
-{
- if (error == 0)
- return ("Successful return: 0");
- if (error > 0)
- return (strerror(error));
-
- switch (error) {
- case DB_INCOMPLETE:
- return ("DB_INCOMPLETE: Cache flush was unable to complete");
- case DB_KEYEMPTY:
- return ("DB_KEYEMPTY: Non-existent key/data pair");
- case DB_KEYEXIST:
- return ("DB_KEYEXIST: Key/data pair already exists");
- case DB_LOCK_DEADLOCK:
- return ("DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock");
- case DB_LOCK_NOTGRANTED:
- return ("DB_LOCK_NOTGRANTED: Lock not granted");
- case DB_NOTFOUND:
- return ("DB_NOTFOUND: No matching key/data pair found");
-#if defined(__USE_DB3)
- case DB_OLD_VERSION:
- return ("DB_OLDVERSION: Database requires a version upgrade");
- case DB_RUNRECOVERY:
- return ("DB_RUNRECOVERY: Fatal error, run database recovery");
-#else /* __USE_DB3 */
- case DB_LOCK_NOTHELD:
- return ("DB_LOCK_NOTHELD:");
- case DB_REGISTERED:
- return ("DB_REGISTERED:");
-#endif /* __USE_DB3 */
- default:
- {
- /*
- * !!!
- * Room for a 64-bit number + slop. This buffer is only used
- * if we're given an unknown error, which should never happen.
- * Note, however, we're no longer thread-safe if it does.
- */
- static char ebuf[40];
-
- (void)snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", error);
- return(ebuf);
- }
- }
- /*@notreached@*/
-}
-
-static int db_env_create(DB_ENV **dbenvp, int foo)
-{
- DB_ENV *dbenv;
-
- if (dbenvp == NULL)
- return 1;
- dbenv = xcalloc(1, sizeof(*dbenv));
-
- *dbenvp = dbenv;
- return 0;
-}
-#endif /* __USE_DB2 */
-
-static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
- int rc = 0;
-
- rc = error;
-
- if (printit && rc) {
- if (msg)
- rpmError(RPMERR_DBERR, _("db%d error(%d) from %s: %s\n"),
- dbi->dbi_api, rc, msg, db_strerror(error));
- else
- rpmError(RPMERR_DBERR, _("db%d error(%d): %s\n"),
- dbi->dbi_api, rc, db_strerror(error));
- }
-
- return rc;
-}
-
-static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
- /*@unused@*/ const char * dbsubfile)
-{
- DB_ENV * dbenv = dbi->dbi_dbenv;
- int rc;
-
-#if defined(__USE_DB3)
- rpmdb rpmdb = dbi->dbi_rpmdb;
-
- if (dbenv == NULL) {
- dbi->dbi_dbenv = NULL;
- return 0;
- }
-
- rc = dbenv->close(dbenv, 0);
- rc = cvtdberr(dbi, "dbenv->close", rc, _debug);
-
- if (dbfile)
- rpmMessage(RPMMESS_DEBUG, _("closed db environment %s/%s\n"),
- dbhome, dbfile);
-
- if (rpmdb->db_remove_env || dbi->dbi_tear_down) {
- int xx;
-
- xx = db_env_create(&dbenv, 0);
- xx = cvtdberr(dbi, "db_env_create", rc, _debug);
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
- xx = dbenv->remove(dbenv, dbhome, 0);
-#else
- xx = dbenv->remove(dbenv, dbhome, NULL, 0);
-#endif
- xx = cvtdberr(dbi, "dbenv->remove", rc, _debug);
-
- if (dbfile)
- rpmMessage(RPMMESS_DEBUG, _("removed db environment %s/%s\n"),
- dbhome, dbfile);
-
- }
-
-#else /* __USE_DB3 */
- rc = db_appexit(dbenv);
- rc = cvtdberr(dbi, "db_appexit", rc, _debug);
- free(dbenv);
-#endif /* __USE_DB3 */
- dbi->dbi_dbenv = NULL;
- return rc;
-}
-
-static int db2_fsync_disable(/*@unused@*/ int fd) {
- return 0;
-}
-
-static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
- /*@unused@*/ const char * dbsubfile, /*@out@*/ DB_ENV **dbenvp)
-{
- rpmdb rpmdb = dbi->dbi_rpmdb;
- DB_ENV *dbenv = NULL;
- int eflags;
- int rc;
-
- if (dbenvp == NULL)
- return 1;
-
- /* XXX HACK */
- if (rpmdb->db_errfile == NULL)
- rpmdb->db_errfile = stderr;
-
- eflags = (dbi->dbi_oeflags | dbi->dbi_eflags);
- if ( dbi->dbi_mode & O_CREAT) eflags |= DB_CREATE;
-
- if (dbfile)
- rpmMessage(RPMMESS_DEBUG, _("opening db environment %s/%s %s\n"),
- dbhome, dbfile, prDbiOpenFlags(eflags, 1));
-
- rc = db_env_create(&dbenv, dbi->dbi_cflags);
- rc = cvtdberr(dbi, "db_env_create", rc, _debug);
- if (rc)
- goto errxit;
-
-#if defined(__USE_DB3)
- { int xx;
- dbenv->set_errcall(dbenv, rpmdb->db_errcall);
- dbenv->set_errfile(dbenv, rpmdb->db_errfile);
- dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
- /* dbenv->set_paniccall(???) */
- dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
- (dbi->dbi_verbose & DB_VERB_CHKPOINT));
- dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
- (dbi->dbi_verbose & DB_VERB_DEADLOCK));
- dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
- (dbi->dbi_verbose & DB_VERB_RECOVERY));
- dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
- (dbi->dbi_verbose & DB_VERB_WAITSFOR));
- /* dbenv->set_lg_max(???) */
- /* dbenv->set_lk_conflicts(???) */
- /* dbenv->set_lk_detect(???) */
- /* dbenv->set_lk_max(???) */
- xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mp_mmapsize);
- xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
- xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_mp_size, 0);
- xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
- /* dbenv->set_tx_max(???) */
- /* dbenv->set_tx_recover(???) */
- if (dbi->dbi_no_fsync) {
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
- xx = db_env_set_func_fsync(db3_fsync_disable);
-#else
- xx = dbenv->set_func_fsync(dbenv, db3_fsync_disable);
-#endif
- xx = cvtdberr(dbi, "db_env_set_func_fsync", xx, _debug);
- }
- }
-#else /* __USE_DB3 */
- dbenv->db_errcall = rpmdb->db_errcall;
- dbenv->db_errfile = rpmdb->db_errfile;
- dbenv->db_errpfx = rpmdb->db_errpfx;
- dbenv->db_verbose = dbi->dbi_verbose;
- dbenv->mp_mmapsize = dbi->dbi_mp_mmapsize; /* XXX default is 10 Mb */
- dbenv->mp_size = dbi->dbi_mp_size; /* XXX default is 128 Kb */
-#endif /* __USE_DB3 */
-
-#if defined(__USE_DB3)
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
- rc = dbenv->open(dbenv, dbhome, eflags, dbi->dbi_perms);
-#else
- rc = dbenv->open(dbenv, dbhome, NULL, eflags, dbi->dbi_perms);
-#endif
- rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
- if (rc)
- goto errxit;
-#else /* __USE_DB3 */
- rc = db_appinit(dbhome, NULL, dbenv, eflags);
- rc = cvtdberr(dbi, "db_appinit", rc, _debug);
- if (rc)
- goto errxit;
-#endif /* __USE_DB3 */
-
- *dbenvp = dbenv;
-
- return 0;
-
-errxit:
-
-#if defined(__USE_DB3)
- if (dbenv) {
- int xx;
- xx = dbenv->close(dbenv, 0);
- xx = cvtdberr(dbi, "dbenv->close", xx, _debug);
- }
-#else /* __USE_DB3 */
- if (dbenv) free(dbenv);
-#endif /* __USE_DB3 */
- return rc;
-}
-
-#endif /* __USE_DB2 || __USE_DB3 */
-
-static int db2sync(dbiIndex dbi, unsigned int flags)
-{
- DB * db = dbi->dbi_db;
- int rc;
-
-#if defined(__USE_DB2) || defined(__USE_DB3)
- int _printit;
-
- rc = db->sync(db, flags);
- /* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
- _printit = (rc == DB_INCOMPLETE ? 0 : _debug);
- rc = cvtdberr(dbi, "db->sync", rc, _printit);
-#else /* __USE_DB2 || __USE_DB3 */
- rc = db->sync(db, flags);
-#endif /* __USE_DB2 || __USE_DB3 */
-
- return rc;
-}
-
-static int db2c_del(dbiIndex dbi, DBC * dbcursor, u_int32_t flags)
-{
- int rc;
-
- rc = dbcursor->c_del(dbcursor, flags);
- rc = cvtdberr(dbi, "dbcursor->c_del", rc, _debug);
- return rc;
-}
-
-/*@unused@*/ static int db2c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp,
- u_int32_t flags)
-{
- int rc = 0;
-
-#if defined(__USE_DB3)
- rc = dbcursor->c_dup(dbcursor, dbcp, flags);
- rc = cvtdberr(dbi, "dbcursor->c_dup", rc, _debug);
-#endif
- return rc;
-}
-
-static int db2c_get(dbiIndex dbi, DBC * dbcursor,
- DBT * key, DBT * data, u_int32_t flags)
-{
- int _printit;
- int rc;
- int rmw;
-
-#ifdef NOTYET
- if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
- rmw = DB_RMW;
- else
-#endif
- rmw = 0;
-
- rc = dbcursor->c_get(dbcursor, key, data, rmw | flags);
-
- /* XXX DB_NOTFOUND can be returned */
- _printit = (rc == DB_NOTFOUND ? 0 : _debug);
- rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
- return rc;
-}
-
-static int db2c_put(dbiIndex dbi, /*@only@*/ DBC * dbcursor,
- DBT * key, DBT * data, u_int32_t flags)
-{
- int rc;
-
- rc = dbcursor->c_put(dbcursor, key, data, flags);
-
- rc = cvtdberr(dbi, "dbcursor->c_put", rc, _debug);
- return rc;
-}
-
-static INLINE int db2c_close(dbiIndex dbi, DBC * dbcursor)
-{
- int rc;
-
- rc = dbcursor->c_close(dbcursor);
- rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
- return rc;
-}
-
-static INLINE int db2c_open(dbiIndex dbi, /*@out@*/ DBC ** dbcp)
-{
- DB * db = dbi->dbi_db;
- DB_TXN * txnid = NULL;
- int rc;
-
-#if defined(__USE_DB3)
- int flags;
-
- if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
- flags = DB_WRITECURSOR;
- else
- flags = 0;
- rc = db->cursor(db, txnid, dbcp, flags);
-#else /* __USE_DB3 */
- rc = db->cursor(db, txnid, dbcp);
-#endif /* __USE_DB3 */
- rc = cvtdberr(dbi, "db2c_open", rc, _debug);
-
- return rc;
-}
-
-static int db2cclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor,
- unsigned int flags)
-{
- int rc = 0;
-
- /* XXX per-iterator cursors */
- if (flags == 1)
- return db2c_close(dbi, dbcursor);
-
- if (!dbi->dbi_use_cursors)
- return 0;
-
- if (dbcursor == NULL)
- dbcursor = dbi->dbi_rmw;
- if (dbcursor) {
- if (dbcursor == dbi->dbi_rmw)
- dbi->dbi_rmw = NULL;
- rc = db2c_close(dbi, dbcursor);
- }
- return rc;
-}
-
-static int db2copen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags)
-{
- DBC * dbcursor;
- int rc = 0;
-
- /* XXX per-iterator cursors */
- if (flags == 1)
- return db2c_open(dbi, dbcp);
-
- if (!dbi->dbi_use_cursors) {
- if (dbcp) *dbcp = NULL;
- return 0;
- }
-
- if ((dbcursor = dbi->dbi_rmw) == NULL) {
- if ((rc = db2c_open(dbi, &dbcursor)) == 0)
- dbi->dbi_rmw = dbcursor;
- }
-
- if (dbcp)
- *dbcp = dbi->dbi_rmw;
-
- return rc;
-}
-
-static int db2cput(dbiIndex dbi, DBC * dbcursor,
- const void * keyp, size_t keylen,
- const void * datap, size_t datalen,
- /*@unused@*/ unsigned int flags)
-{
- DB * db = dbi->dbi_db;
- DB_TXN * txnid = NULL;
- DBT key, data;
- int rc;
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
- key.data = (void *)keyp;
- key.size = keylen;
- data.data = (void *)datap;
- data.size = datalen;
-
- if (dbcursor == NULL) {
- rc = db->put(db, txnid, &key, &data, 0);
- rc = cvtdberr(dbi, "db->put", rc, _debug);
- } else {
-
- rc = db2c_put(dbi, dbcursor, &key, &data, DB_AFTER);
-
- }
-
- return rc;
-}
-
-static int db2cdel(dbiIndex dbi, DBC * dbcursor,
- const void * keyp, size_t keylen,
- /*@unused@*/ unsigned int flags)
-{
- DB * db = dbi->dbi_db;
- DB_TXN * txnid = NULL;
- DBT key, data;
- int rc;
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
-
- key.data = (void *)keyp;
- key.size = keylen;
-
- if (dbcursor == NULL) {
- rc = db->del(db, txnid, &key, 0);
- rc = cvtdberr(dbi, "db->del", rc, _debug);
- } else {
-
- rc = db2c_get(dbi, dbcursor, &key, &data, DB_SET);
-
- if (rc == 0) {
- /* XXX TODO: loop over duplicates */
- rc = db2c_del(dbi, dbcursor, 0);
- }
-
- }
-
- return rc;
-}
-
-static int db2cget(dbiIndex dbi, DBC * dbcursor,
- void ** keyp, size_t * keylen,
- void ** datap, size_t * datalen,
- /*@unused@*/ unsigned int flags)
-{
- DB * db = dbi->dbi_db;
- DB_TXN * txnid = NULL;
- DBT key, data;
- int rc;
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
- if (keyp) key.data = *keyp;
- if (keylen) key.size = *keylen;
- if (datap) data.data = *datap;
- if (datalen) data.size = *datalen;
-
- if (dbcursor == NULL) {
- int _printit;
- rc = db->get(db, txnid, &key, &data, 0);
- /* XXX DB_NOTFOUND can be returned */
- _printit = (rc == DB_NOTFOUND ? 0 : _debug);
- rc = cvtdberr(dbi, "db->get", rc, _printit);
- } else {
-
- /* XXX W2DO? db2 does DB_FIRST on uninitialized cursor? */
- rc = db2c_get(dbi, dbcursor, &key, &data,
- key.data == NULL ? DB_NEXT : DB_SET);
-
- }
-
- if (rc == 0) {
- if (keyp) *keyp = key.data;
- if (keylen) *keylen = key.size;
- if (datap) *datap = data.data;
- if (datalen) *datalen = data.size;
- }
-
- return rc;
-}
-
-static int db2ccount(dbiIndex dbi, DBC * dbcursor,
- /*@out@*/ unsigned int * countp,
- /*@unused@*/ unsigned int flags)
-{
- return EINVAL;
-}
-
-static int db2byteswapped(dbiIndex dbi)
-{
- int rc = 0;
-
-#if defined(__USE_DB3)
- DB * db = dbi->dbi_db;
-
- rc = db->get_byteswapped(db);
-#endif /* __USE_DB3 */
-
- return rc;
-}
-
-static int db2stat(dbiIndex dbi, unsigned int flags)
-{
- return EINVAL;
-}
-
-static int db2close(/*@only@*/ dbiIndex dbi, unsigned int flags)
-{
- rpmdb rpmdb = dbi->dbi_rpmdb;
- const char * urlfn = NULL;
- const char * dbhome;
- const char * dbfile;
- const char * dbsubfile;
- DB * db = dbi->dbi_db;
- int rc = 0, xx;
-
- urlfn = rpmGenPath(
- (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root),
- (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home),
- NULL);
- (void) urlPath(urlfn, &dbhome);
- if (dbi->dbi_temporary) {
- dbfile = NULL;
- dbsubfile = NULL;
- } else {
-#ifdef HACK
- dbfile = (dbi->dbi_file ? dbi->dbi_file : db2basename);
- dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
-#else
- dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
- dbsubfile = NULL;
-#endif
- }
-
-#if defined(__USE_DB2) || defined(__USE_DB3)
-
- if (dbi->dbi_rmw)
- db2cclose(dbi, NULL, 0);
-
- if (db) {
- rc = db->close(db, 0);
- rc = cvtdberr(dbi, "db->close", rc, _debug);
- db = dbi->dbi_db = NULL;
-
- rpmMessage(RPMMESS_DEBUG, _("closed db index %s/%s\n"),
- dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)));
-
- }
-
- if (dbi->dbi_dbinfo) {
- free(dbi->dbi_dbinfo);
- dbi->dbi_dbinfo = NULL;
- }
-
- if (dbi->dbi_use_dbenv)
- xx = db_fini(dbi, dbhome, dbfile, dbsubfile);
-
-#else /* __USE_DB2 || __USE_DB3 */
-
- rc = db->close(db);
-
-#endif /* __USE_DB2 || __USE_DB3 */
- dbi->dbi_db = NULL;
-
- urlfn = _free(urlfn);
-
- dbi = db3Free(dbi);
-
- return rc;
-}
-
-static int db2open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
-{
- /*@-nestedextern@*/
- extern struct _dbiVec db2vec;
- /*@=nestedextern@*/
- const char * urlfn = NULL;
- const char * dbhome;
- const char * dbfile;
- const char * dbsubfile;
- dbiIndex dbi = NULL;
- int rc = 0;
- int xx;
-
-#if defined(__USE_DB2) || defined(__USE_DB3)
- DB * db = NULL;
- DB_ENV * dbenv = NULL;
- u_int32_t oflags;
- int _printit;
-
- if (dbip)
- *dbip = NULL;
- if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
- return 1;
- dbi->dbi_api = DB_VERSION_MAJOR;
-
- urlfn = rpmGenPath(
- (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root),
- (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home),
- NULL);
- (void) urlPath(urlfn, &dbhome);
- if (dbi->dbi_temporary) {
- dbfile = NULL;
- dbsubfile = NULL;
- } else {
-#ifdef HACK
- dbfile = (dbi->dbi_file ? dbi->dbi_file : db2basename);
- dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
-#else
- dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
- dbsubfile = NULL;
-#endif
- }
-
- oflags = (dbi->dbi_oeflags | dbi->dbi_oflags);
- oflags &= ~DB_TRUNCATE; /* XXX this is dangerous */
-
-#if 0 /* XXX rpmdb: illegal flag combination specified to DB->open */
- if ( dbi->dbi_mode & O_EXCL) oflags |= DB_EXCL;
-#endif
-
- if (dbi->dbi_temporary) {
- oflags &= ~DB_RDONLY;
- oflags |= DB_CREATE;
- } else {
- if(!(dbi->dbi_mode & O_RDWR)) oflags |= DB_RDONLY;
- if ( dbi->dbi_mode & O_CREAT) oflags |= DB_CREATE;
- if ( dbi->dbi_mode & O_TRUNC) oflags |= DB_TRUNCATE;
- }
-
- dbi->dbi_dbinfo = NULL;
-
- if (dbi->dbi_use_dbenv)
- rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
-
- rpmMessage(RPMMESS_DEBUG, _("opening db index %s/%s %s mode=0x%x\n"),
- dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)),
- prDbiOpenFlags(oflags, 0), dbi->dbi_mode);
-
- if (rc == 0) {
-#if defined(__USE_DB3)
- rc = db_create(&db, dbenv, dbi->dbi_cflags);
- rc = cvtdberr(dbi, "db_create", rc, _debug);
- if (rc == 0) {
- if (dbi->dbi_lorder) {
- rc = db->set_lorder(db, dbi->dbi_lorder);
- rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
- }
- if (dbi->dbi_cachesize) {
- rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
- rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
- }
- if (dbi->dbi_pagesize) {
- rc = db->set_pagesize(db, dbi->dbi_pagesize);
- rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
- }
- if (rpmdb->db_malloc) {
- rc = db->set_malloc(db, rpmdb->db_malloc);
- rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
- }
- if (oflags & DB_CREATE) {
- switch(dbi->dbi_type) {
- default:
- case DB_HASH:
- if (dbi->dbi_h_ffactor) {
- rc = db->set_h_ffactor(db, dbi->dbi_h_ffactor);
- rc = cvtdberr(dbi, "db->set_h_ffactor", rc, _debug);
- }
- if (dbi->dbi_h_hash_fcn) {
- rc = db->set_h_hash(db, dbi->dbi_h_hash_fcn);
- rc = cvtdberr(dbi, "db->set_h_hash", rc, _debug);
- }
- if (dbi->dbi_h_nelem) {
- rc = db->set_h_nelem(db, dbi->dbi_h_nelem);
- rc = cvtdberr(dbi, "db->set_h_nelem", rc, _debug);
- }
- if (dbi->dbi_h_flags) {
- rc = db->set_flags(db, dbi->dbi_h_flags);
- rc = cvtdberr(dbi, "db->set_h_flags", rc, _debug);
- }
- if (dbi->dbi_h_dup_compare_fcn) {
- rc = db->set_dup_compare(db, dbi->dbi_h_dup_compare_fcn);
- rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug);
- }
- break;
- case DB_BTREE:
- case DB_RECNO:
- case DB_QUEUE:
- break;
- }
- }
- dbi->dbi_dbinfo = NULL;
-
- { const char * dbfullpath;
- const char * dbpath;
- char * t;
- int nb;
-
- nb = strlen(dbhome);
- if (dbfile) nb += 1 + strlen(dbfile);
- dbfullpath = t = alloca(nb + 1);
-
- t = stpcpy(t, dbhome);
- if (dbfile)
- t = stpcpy( stpcpy( t, "/"), dbfile);
- dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary)
- ? dbfullpath : dbfile;
-
- rc = db->open(db, dbpath, dbsubfile,
- dbi->dbi_type, oflags, dbi->dbi_perms);
- }
-
- /* XXX return rc == errno without printing */
- _printit = (rc > 0 ? 0 : _debug);
- xx = cvtdberr(dbi, "db->open", rc, _printit);
-
- if (rc == 0 && dbi->dbi_get_rmw_cursor) {
- DBC * dbcursor = NULL;
- DB_TXN * txnid = NULL;
- xx = db->cursor(db, txnid, &dbcursor,
- ((oflags & DB_RDONLY) ? 0 : DB_WRITECURSOR));
- xx = cvtdberr(dbi, "db->cursor", xx, _debug);
- dbi->dbi_rmw = dbcursor;
- } else
- dbi->dbi_rmw = NULL;
-
- if (rc == 0 && dbi->dbi_lockdbfd) {
- int fdno = -1;
-
- if (!(db->fd(db, &fdno) == 0 && fdno >= 0)) {
- rc = 1;
- } else {
- struct flock l;
- l.l_whence = 0;
- l.l_start = 0;
- l.l_len = 0;
- l.l_type = (dbi->dbi_mode & O_RDWR) ? F_WRLCK : F_RDLCK;
- l.l_pid = 0;
-
- if (fcntl(fdno, F_SETLK, (void *) &l)) {
- rpmError(RPMERR_FLOCK,
- _("cannot get %s lock on %s/%s\n"),
- ((dbi->dbi_mode & O_RDWR)
- ? _("exclusive") : _("shared")),
- dbhome, dbfile);
- rc = 1;
- } else if (dbfile) {
- rpmMessage(RPMMESS_DEBUG,
- _("locked db index %s/%s\n"),
- dbhome, dbfile);
- }
- }
- }
- }
- }
-#else /* __USE_DB3 */
- { DB_INFO * dbinfo = xcalloc(1, sizeof(*dbinfo));
- dbinfo->db_cachesize = dbi->dbi_cachesize;
- dbinfo->db_lorder = dbi->dbi_lorder;
- dbinfo->db_pagesize = dbi->dbi_pagesize;
- dbinfo->db_malloc = rpmdb->db_malloc;
- if (oflags & DB_CREATE) {
- switch(db3_to_dbtype(dbi->dbi_type)) {
- default:
- case DB_HASH:
- dbinfo->h_ffactor = dbi->dbi_h_ffactor;
- dbinfo->h_hash = dbi->dbi_h_hash_fcn;
- dbinfo->h_nelem = dbi->dbi_h_nelem;
- dbinfo->flags = dbi->dbi_h_flags;
- break;
- }
- }
- dbi->dbi_dbinfo = dbinfo;
-
- { const char * dbfullpath;
- const char * dbpath;
- char * t;
- int nb;
-
- nb = strlen(dbhome);
- if (dbfile) nb += 1 + strlen(dbfile);
- dbfullpath = t = alloca(nb + 1);
-
- t = stpcpy(t, dbhome);
- if (dbfile)
- t = stpcpy( stpcpy( t, "/"), dbfile);
- dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary)
- ? dbfullpath : dbfile;
-
- rc = db_open(dbpath, db3_to_dbtype(dbi->dbi_type), oflags,
- dbi->dbi_perms, dbenv, dbinfo, &db);
- }
-
- /* XXX return rc == errno without printing */
- _printit = (rc > 0 ? 0 : _debug);
- xx = cvtdberr(dbi, "db->open", rc, _printit);
- }
-#endif /* __USE_DB3 */
- }
-
- dbi->dbi_db = db;
- dbi->dbi_dbenv = dbenv;
-
-#else /* __USE_DB2 || __USE_DB3 */
- void * dbopeninfo = NULL;
-
- if (dbip)
- *dbip = NULL;
- if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
- return 1;
-
- dbi->dbi_db = dbopen(dbfile, dbi->dbi_mode, dbi->dbi_perms,
- db3_to_dbtype(dbi->dbi_type), dbopeninfo);
-
- /* XXX return rc == errno without printing */
- if (dbi->dbi_db == NULL) rc = errno;
-#endif /* __USE_DB2 || __USE_DB3 */
-
- if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
- dbi->dbi_vec = &db2vec;
- *dbip = dbi;
- } else
- db2close(dbi, 0);
-
- urlfn = _free(urlfn);
-
- return rc;
-}
-
-/** \ingroup db2
- */
-struct _dbiVec db2vec = {
- DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
- db2open, db2close, db2sync, db2copen, db2cclose, db2cdel, db2cget, db2cput,
- db2ccount, db2byteswapped, db2stat
-};
-
-#endif /* DB_VERSION_MAJOR == 2 */
diff --git a/rpmdb/db3.c b/rpmdb/db3.c
index 34fe0747a..04c64bd57 100644
--- a/rpmdb/db3.c
+++ b/rpmdb/db3.c
@@ -4,13 +4,6 @@
static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
-#ifdef __LCLINT__
-typedef unsigned int u_int32_t;
-typedef unsigned short u_int16_t;
-typedef unsigned char u_int8_t;
-typedef int int32_t;
-#endif
-
#include "system.h"
#if defined(HAVE_FTOK) && defined(HAVE_SYS_IPC_H)
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index a2a4f758c..7fadd9c94 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -317,7 +317,6 @@ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag, /*@unused@*/ unsigned int flags)
if (dbix < 0 || dbix >= dbiTagsMax)
return NULL;
-
/* Is this index already open ? */
if ((dbi = rpmdb->_dbi[dbix]) != NULL)
return dbi;
diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h
index 8764f3f31..8f77db522 100644
--- a/rpmdb/rpmdb.h
+++ b/rpmdb/rpmdb.h
@@ -10,6 +10,13 @@
#include "fprint.h"
+#ifdef __LCLINT__
+typedef unsigned int u_int32_t;
+typedef unsigned short u_int16_t;
+typedef unsigned char u_int8_t;
+typedef int int32_t;
+#endif
+
typedef /*@abstract@*/ struct _dbiIndexItem * dbiIndexItem;
typedef /*@abstract@*/ struct _dbiIndex * dbiIndex;
diff --git a/rpmqv.c b/rpmqv.c
index d77569b39..e1cdf7548 100755
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -786,6 +786,15 @@ int main(int argc, const char ** argv)
rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
+#if 0
+ { const char ** avp;
+ fprintf(stderr, "==> argv[%d]:", argc);
+ for (avp = argv; *avp; avp++)
+ fprintf(stderr, " '%s'", *avp);
+ fprintf(stderr, "\n");
+ }
+#endif
+
/* Make a first pass through the arguments, looking for --rcfile */
/* We need to handle that before dealing with the rest of the arguments. */
/*@-nullpass -temptrans@*/
@@ -904,10 +913,8 @@ int main(int argc, const char ** argv)
#endif
case GETOPT_EXCLUDEPATH:
- /*@-nullderef@*/ /* LCL: optarg != NULL */
- if (optarg == NULL || *optArg != '/')
+ if (optArg == NULL || *optArg != '/')
argerror(_("exclude paths must begin with a /"));
- /*@=nullderef@*/
relocations = xrealloc(relocations,
sizeof(*relocations) * (numRelocations + 1));
@@ -919,12 +926,10 @@ int main(int argc, const char ** argv)
case GETOPT_RELOCATE:
{ char * newPath = NULL;
- /*@-nullderef -nullpass@*/ /* LCL: optarg != NULL */
- if (optarg == NULL || *optArg != '/')
+ if (optArg == NULL || *optArg != '/')
argerror(_("relocations must begin with a /"));
if (!(newPath = strchr(optArg, '=')))
argerror(_("relocations must contain a ="));
- /*@=nullderef =nullpass@*/
*newPath++ = '\0';
if (*newPath != '/')
argerror(_("relocations must have a / following the ="));
@@ -975,21 +980,21 @@ int main(int argc, const char ** argv)
#endif /* IAM_RPMK */
case GETOPT_DEFINEMACRO:
- /*@-nullderef -nullpass@*/ /* LCL: optarg != NULL */
- if (optarg == NULL) break; /* XXX can't happen. */
- (void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
- (void) rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
- /*@=nullderef =nullpass@*/
+ if (optArg) {
+ (void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
+ (void) rpmDefineMacro(&rpmCLIMacroContext, optArg,RMIL_CMDLINE);
+ }
noUsageMsg = 1;
break;
case GETOPT_EVALMACRO:
- if (optarg == NULL) break; /* XXX can't happen. */
- { const char *val = rpmExpand(optArg, NULL);
- fprintf(stdout, "%s\n", val);
- free((void *)val);
+ if (optArg) {
+ const char *val = rpmExpand(optArg, NULL);
+ fprintf(stdout, "%s\n", val);
+ val = _free(val);
+ }
noUsageMsg = 1;
- } break;
+ break;
#if defined(GETOPT_RCFILE)
case GETOPT_RCFILE: