mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
README.Coding: add "Error and out logic"
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Simo <simo@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Thu Aug 10 14:36:01 CEST 2017 on sn-devel-144
This commit is contained in:
parent
d0381a3cf4
commit
62925cfa6e
@ -445,6 +445,55 @@ The only exception is the test code that depends repeated use of calls
|
||||
like CHECK_STATUS, CHECK_VAL and others.
|
||||
|
||||
|
||||
Error and out logic
|
||||
-------------------
|
||||
|
||||
Don't do this:
|
||||
|
||||
frame = talloc_stackframe();
|
||||
|
||||
if (ret == LDB_SUCCESS) {
|
||||
if (result->count == 0) {
|
||||
ret = LDB_ERR_NO_SUCH_OBJECT;
|
||||
} else {
|
||||
struct ldb_message *match =
|
||||
get_best_match(dn, result);
|
||||
if (match == NULL) {
|
||||
TALLOC_FREE(frame);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
*msg = talloc_move(mem_ctx, &match);
|
||||
}
|
||||
}
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
|
||||
It should be:
|
||||
|
||||
frame = talloc_stackframe();
|
||||
|
||||
if (ret != LDB_SUCCESS) {
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (result->count == 0) {
|
||||
TALLOC_FREE(frame);
|
||||
return LDB_ERR_NO_SUCH_OBJECT;
|
||||
}
|
||||
|
||||
match = get_best_match(dn, result);
|
||||
if (match == NULL) {
|
||||
TALLOC_FREE(frame);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
*msg = talloc_move(mem_ctx, &match);
|
||||
TALLOC_FREE(frame);
|
||||
return LDB_SUCCESS;
|
||||
|
||||
|
||||
DEBUG statements
|
||||
----------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user