[SCM] Samba Shared Repository - branch master updated

Kai Blin kai at samba.org
Wed Nov 18 03:51:09 MST 2009


The branch, master has been updated
       via  054833a... README.coding: Update rules about code blocks and braces.
      from  61f5adb... selftest: Subunit/Filter.pm only allow expected failures without errors

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


- Log -----------------------------------------------------------------
commit 054833a892cdbf3ef4efbd8eec468cf4b287c95d
Author: Kai Blin <kai at samba.org>
Date:   Wed Nov 18 11:43:01 2009 +0100

    README.coding: Update rules about code blocks and braces.

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

Summary of changes:
 README.Coding |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README.Coding b/README.Coding
index ae09349..ddeacc9 100644
--- a/README.Coding
+++ b/README.Coding
@@ -15,9 +15,10 @@ style should never outweigh coding itself and so the guidelines
 described here are hopefully easy enough to follow as they are very
 common and supported by tools and editors.
 
-The basic style, also mentioned in prog_guide4.txt, is the Linux kernel coding 
-style (See Documentation/CodingStyle in the kernel source tree). This closely 
-matches what most Samba developers use already anyways.
+The basic style, also mentioned in prog_guide4.txt, is the Linux kernel coding
+style (See Documentation/CodingStyle in the kernel source tree). This closely
+matches what most Samba developers use already anyways, with a few exceptions as
+mentioned below.
 
 But to save you the trouble of reading the Linux kernel style guide, here
 are the highlights.
@@ -125,23 +126,24 @@ This is bad:
 
 	if ( x == 1 )
 
-Yes we have a lot of code that uses the second form and we are trying 
+Yes we have a lot of code that uses the second form and we are trying
 to clean it up without being overly intrusive.
 
 Note that this is a rule about parentheses following keywords and not
-functions.  Don't insert a space between the name and left parentheses when 
+functions.  Don't insert a space between the name and left parentheses when
 invoking functions.
 
 Braces for code blocks used by for, if, switch, while, do..while, etc.
-should begin on the same line as the statement keyword and end on a line 
-of their own.  NOTE: Functions are different and the beginning left brace
-should begin on a line of its own.
+should begin on the same line as the statement keyword and end on a line
+of their own. You should always include braces, even if the block only
+contains one statement.  NOTE: Functions are different and the beginning left
+brace should begin on a line of its own.
 
 If the beginning statement has to be broken across lines due to length,
 the beginning brace should be on a line of its own.
 
-The exception to the ending rule is when the closing brace is followed by 
-another language keyword such as else or the closing while in a do..while 
+The exception to the ending rule is when the closing brace is followed by
+another language keyword such as else or the closing while in a do..while
 loop.
 
 Good examples::
@@ -150,13 +152,17 @@ Good examples::
 		printf("good\n");
 	}
 
-	for (x=1;
-	     x<10;
-	     x++)
-	{
+	for (x=1; x<10; x++) {
 		print("%d\n", x);
 	}
 
+	for (really_really_really_really_long_var_name=0;
+	     really_really_really_really_long_var_name<10;
+	     really_really_really_really_long_var_name++)
+	{
+		print("%d\n", really_really_really_really_long_var_name);
+	}
+
 	do {
 		printf("also good\n");
 	} while (1);
@@ -166,7 +172,17 @@ Bad examples::
 	while (1)
 	{
 		print("I'm in a loop!\n"); }
-	
+
+	for (x=1;
+	     x<10;
+	     x++)
+	{
+		print("no good\n");
+	}
+
+	if (i < 10)
+		print("I should be in braces.\n");
+
 
 Goto
 ----


-- 
Samba Shared Repository


More information about the samba-cvs mailing list