diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-09-13 15:26:51 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-13 15:26:51 -0700 |
| commit | bb57f055aeede67cb2ff68a6cf96dbd9dc8a6321 (patch) | |
| tree | a40e2a957f3f0d08cb9fdc8e8a6453f6af3dbe0d | |
| parent | Merge branch 'ps/stash-keep-untrack-empty-fix' into maint-2.46 (diff) | |
| parent | CodingGuidelines: spaces around C operators (diff) | |
| download | git-bb57f055aeede67cb2ff68a6cf96dbd9dc8a6321.tar.gz git-bb57f055aeede67cb2ff68a6cf96dbd9dc8a6321.zip | |
Merge branch 'jc/coding-style-c-operator-with-spaces' into maint-2.46
Write down whitespacing rules around C opeators.
* jc/coding-style-c-operator-with-spaces:
CodingGuidelines: spaces around C operators
| -rw-r--r-- | Documentation/CodingGuidelines | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 8fb873358a..5edd3a0b9d 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -293,7 +293,9 @@ For C programs: v12.01, 2022-03-28). - Variables have to be declared at the beginning of the block, before - the first statement (i.e. -Wdeclaration-after-statement). + the first statement (i.e. -Wdeclaration-after-statement). It is + encouraged to have a blank line between the end of the declarations + and the first statement in the block. - NULL pointers shall be written as NULL, not as 0. @@ -313,6 +315,13 @@ For C programs: while( condition ) func (bar+1); + - A binary operator (other than ",") and ternary conditional "?:" + have a space on each side of the operator to separate it from its + operands. E.g. "A + 1", not "A+1". + + - A unary operator (other than "." and "->") have no space between it + and its operand. E.g. "(char *)ptr", not "(char *) ptr". + - Do not explicitly compare an integral value with constant 0 or '\0', or a pointer value with constant NULL. For instance, to validate that counted array <ptr, cnt> is initialized but has no elements, write: |
