[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon Nov 16 02:56:04 MST 2009


The branch, master has been updated
       via  adff5ef... README.Coding: add section about usage of helper variables
       via  6c6c8e9... README.Coding: fix error in "good example"
       via  0762893... s3:libsmb: avoid passing a function call as function parameter
      from  8880170... s4:dsdb LDB attribute lists must always be a static const char **.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit adff5ef28f8763c70aa24071940f4c3df4a5cc3a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 16 10:52:27 2009 +0100

    README.Coding: add section about usage of helper variables
    
    metze

commit 6c6c8e91efb8a534afb629897b402bf3f3945948
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 16 10:51:31 2009 +0100

    README.Coding: fix error in "good example"
    
    metze

commit 0762893c48c7f5a6532ee35ad188c80b8a6f3981
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 16 09:59:58 2009 +0100

    s3:libsmb: avoid passing a function call as function parameter
    
    Using a helper variable makes it easier to "step" into the desired function
    within gdb.
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 README.Coding              |   28 +++++++++++++++++++++++++++-
 source3/libsmb/clifile.c   |   36 ++++++++++++++++++------------------
 source3/libsmb/clifsinfo.c |    6 +++---
 3 files changed, 48 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README.Coding b/README.Coding
index 981da6c..ae09349 100644
--- a/README.Coding
+++ b/README.Coding
@@ -183,7 +183,7 @@ Good Examples::
 		int *z = NULL;
 		int ret = 0;
 
-		if ( y < 10 ) {
+		if (y < 10) {
 			z = malloc(sizeof(int)*y);
 			if (!z) {
 				ret = 1;
@@ -241,3 +241,29 @@ Typedefs
 Samba tries to avoid "typedef struct { .. } x_t;", we always use
 "struct x { .. };". We know there are still those typedefs in the code,
 but for new code, please don't do that.
+
+Make use of helper variables
+----------------------------
+
+Please try to avoid passing function calls as function parameters
+in new code. This makes the code much easier to read and
+it's also easier to use the "step" command within gdb.
+
+Good Example::
+
+	char *name;
+
+	name = get_some_name();
+	if (name == NULL) {
+		...
+	}
+
+	ret = some_function_my_name(name);
+	...
+
+
+Bad Example::
+
+	ret = some_function_my_name(get_some_name());
+	...
+
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 1a09c41..d7fcc4b 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -119,9 +119,9 @@ struct link_state {
 
 static void cli_posix_link_internal_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static struct tevent_req *cli_posix_link_internal_send(TALLOC_CTX *mem_ctx,
@@ -945,9 +945,9 @@ struct ch_state {
 
 static void cli_posix_chown_chmod_internal_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static struct tevent_req *cli_posix_chown_chmod_internal_send(TALLOC_CTX *mem_ctx,
@@ -1843,9 +1843,9 @@ struct doc_state {
 
 static void cli_nt_delete_on_close_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
@@ -2449,9 +2449,9 @@ struct ftrunc_state {
 
 static void cli_ftruncate_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
@@ -2974,9 +2974,9 @@ struct posix_lock_state {
 
 static void cli_posix_unlock_internal_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static struct tevent_req *cli_posix_lock_internal_send(TALLOC_CTX *mem_ctx,
@@ -4770,9 +4770,9 @@ struct unlink_state {
 
 static void cli_posix_unlink_internal_done(struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static struct tevent_req *cli_posix_unlink_internal_send(TALLOC_CTX *mem_ctx,
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 6e23dbc..00fd472 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -206,9 +206,9 @@ struct tevent_req *cli_set_unix_extensions_capabilities_send(
 static void cli_set_unix_extensions_capabilities_done(
 	struct tevent_req *subreq)
 {
-	return tevent_req_simple_finish_ntstatus(
-		subreq, cli_trans_recv(subreq, NULL, NULL, 0, NULL,
-				       NULL, 0, NULL, NULL, 0, NULL));
+	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
+					 NULL, 0, NULL, NULL, 0, NULL);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list