summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_tdb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-04-23 00:36:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:30 -0500
commit9ec83ae25df8e8e55ab1e25de4972ec4d082783b (patch)
tree053b4f03a280e9e3306045a4c5575ba1f208136f /source4/lib/ldb/ldb_tdb/ldb_tdb.c
parent1912124dbfc501c5109f6ac36e125406078d408c (diff)
downloadsamba-9ec83ae25df8e8e55ab1e25de4972ec4d082783b.tar.gz
samba-9ec83ae25df8e8e55ab1e25de4972ec4d082783b.tar.bz2
samba-9ec83ae25df8e8e55ab1e25de4972ec4d082783b.zip
r22471: Convert more code to use proper LDB error codes.
This is a 1 to 1 convertion, next step is to make this code report an error if the basedn is not used, hopefully avoiding an explicit search on the base object in the most common cases. (This used to be commit 50534c84b4577b2d32565a74a4716088f706bfea)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 16ab5b905b..8a6d26ff98 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -198,7 +198,7 @@ int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *m
*/
static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
{
- int ret = 0;
+ int ret = LDB_SUCCESS;
if (ldb_dn_is_special(dn) &&
(ldb_dn_check_special(dn, LTDB_INDEXLIST) ||
@@ -206,7 +206,7 @@ static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
ret = ltdb_reindex(module);
}
- if (ret == 0 &&
+ if (ret == LDB_SUCCESS &&
!(ldb_dn_is_special(dn) &&
ldb_dn_check_special(dn, LTDB_BASEINFO)) ) {
ret = ltdb_increase_sequence_number(module);
@@ -243,7 +243,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
}
ret = ltdb_index_add(module, msg);
- if (ret == -1) {
+ if (ret != LDB_SUCCESS) {
tdb_delete(ltdb->tdb, tdb_key);
}
@@ -278,12 +278,12 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
if (ret == LDB_SUCCESS) {
ret = ltdb_index_one(module, msg, 1);
if (ret != LDB_SUCCESS) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return ret;
}
ret = ltdb_modified(module, msg->dn);
if (ret != LDB_SUCCESS) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return ret;
}
}
@@ -362,40 +362,36 @@ static int ltdb_delete_internal(struct ldb_module *module, struct ldb_dn *dn)
/* in case any attribute of the message was indexed, we need
to fetch the old record */
ret = ltdb_search_dn1(module, dn, msg);
- if (ret != 1) {
+ if (ret != LDB_SUCCESS) {
/* not finding the old record is an error */
- talloc_free(msg);
- return LDB_ERR_NO_SUCH_OBJECT;
+ goto done;
}
ret = ltdb_delete_noindex(module, dn);
if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return LDB_ERR_NO_SUCH_OBJECT;
+ goto done;
}
/* remove one level attribute */
ret = ltdb_index_one(module, msg, 0);
if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
/* remove any indexed attributes */
ret = ltdb_index_del(module, msg);
if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
ret = ltdb_modified(module, dn);
if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
+done:
talloc_free(msg);
- return LDB_SUCCESS;
+ return ret;
}
/*
@@ -718,8 +714,8 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
- if (ltdb_index_del_value(module, dn, &msg->elements[i], j) != 0) {
- ret = LDB_ERR_OTHER;
+ ret = ltdb_index_del_value(module, dn, &msg->elements[i], j);
+ if (ret != LDB_SUCCESS) {
goto failed;
}
}
@@ -739,8 +735,8 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
goto failed;
}
- if (ltdb_modified(module, msg->dn) != LDB_SUCCESS) {
- ret = LDB_ERR_OPERATIONS_ERROR;
+ ret = ltdb_modified(module, msg->dn);
+ if (ret != LDB_SUCCESS) {
goto failed;
}
@@ -835,9 +831,9 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
/* in case any attribute of the message was indexed, we need
to fetch the old record */
tret = ltdb_search_dn1(module, req->op.rename.olddn, msg);
- if (tret != 1) {
+ if (tret != LDB_SUCCESS) {
/* not finding the old record is an error */
- req->handle->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->handle->status = tret;
goto done;
}
@@ -944,10 +940,10 @@ static int ltdb_sequence_number(struct ldb_module *module, struct ldb_request *r
req->op.seq_num.flags = 0;
tret = ltdb_search_dn1(module, dn, msg);
- if (tret != 1) {
+ if (tret != LDB_SUCCESS) {
talloc_free(tmp_ctx);
- req->op.seq_num.seq_num = 0;
/* zero is as good as anything when we don't know */
+ req->op.seq_num.seq_num = 0;
return LDB_SUCCESS;
}