[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Thu Aug 10 12:37:02 UTC 2017
The branch, master has been updated
via 62925cf README.Coding: add "Error and out logic"
from d0381a3 ctdb-tests: Add a big no-op LCP2 IP takeover test
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 62925cfa6e796c546f9450846bb9e110f29139c0
Author: Ralph Boehme <slow at samba.org>
Date: Wed Aug 9 15:24:41 2017 +0200
README.Coding: add "Error and out logic"
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Simo <simo at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Thu Aug 10 14:36:01 CEST 2017 on sn-devel-144
-----------------------------------------------------------------------
Summary of changes:
README.Coding | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
Changeset truncated at 500 lines:
diff --git a/README.Coding b/README.Coding
index 19a363f..e89925c 100644
--- a/README.Coding
+++ b/README.Coding
@@ -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
----------------
--
Samba Shared Repository
More information about the samba-cvs
mailing list