Eliminate last three assert()'s from the backend

- We can trivially handle these "can't happen" cases as EINVAL returns
  instead of blowing up, do so.
This commit is contained in:
Panu Matilainen 2011-04-20 15:41:53 +03:00
parent 7d7a9a24b6
commit 909d3cdc92
1 changed files with 7 additions and 9 deletions

View File

@ -279,10 +279,10 @@ dbiCursor dbiCursorFree(dbiCursor dbc)
int dbiCursorPut(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
{
int rc = EINVAL;
int sane = (key->data != NULL && key->size > 0 &&
data->data != NULL && data->size > 0);
assert(key->data != NULL && key->size > 0 && data->data != NULL && data->size > 0);
if (dbc) {
if (dbc && sane) {
DBC * cursor = dbc->cursor;
rpmdb rdb = dbc->dbi->dbi_rpmdb;
rpmswEnter(&rdb->db_putops, (ssize_t) 0);
@ -298,10 +298,9 @@ int dbiCursorPut(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
int dbiCursorGet(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
{
int rc = EINVAL;
int sane = ((flags == DB_NEXT) || (key->data != NULL && key->size > 0));
assert((flags == DB_NEXT) || (key->data != NULL && key->size > 0));
if (dbc) {
if (dbc && sane) {
DBC * cursor = dbc->cursor;
rpmdb rdb = dbc->dbi->dbi_rpmdb;
int _printit;
@ -321,10 +320,9 @@ int dbiCursorGet(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
int dbiCursorDel(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
{
int rc = EINVAL;
int sane = (key->data != NULL && key->size > 0);
assert(key->data != NULL && key->size > 0);
if (dbc) {
if (dbc && sane) {
DBC * cursor = dbc->cursor;
int _printit;
rpmdb rdb = dbc->dbi->dbi_rpmdb;