aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/CodingGuidelines
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-10-10 13:37:58 -0700
committerJunio C Hamano <gitster@pobox.com>2022-10-10 13:41:11 -0700
commit82dd01d81b1babf6714435b80683e756de1a4d64 (patch)
tree043d829a2d39e49204c89f75e2ef67074fb3cf65 /Documentation/CodingGuidelines
parent442c27dde784049a2c0f8815ac5030817123386c (diff)
downloadgit-82dd01d81b1babf6714435b80683e756de1a4d64.tar.gz
CodingGuidelines: allow declaring variables in for loops
Since 44ba10d6712 (revision: use C99 declaration of variable in for() loop, 2021-11-14) released with v2.35.0 we've had a variable declared with in a for loop. Since then we've had inadvertent follow-ups to that with at least cb2607759e2 (merge-ort: store more specific conflict information, 2022-06-18) released with v2.38.0. As November 2022 is within the window of this upcoming release, let's update the guideline to allow this. We can have the promised "revisit" discussion while this patch cooks, and drop it if it turns out that it is still premature, which is not expected to happen at this moment. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/CodingGuidelines')
-rw-r--r--Documentation/CodingGuidelines10
1 files changed, 2 insertions, 8 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 8afda28cfc..f9affc4050 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -232,18 +232,12 @@ For C programs:
. since early 2021 with 765dc168882, we have been using variadic
macros, mostly for printf-like trace and debug macros.
- These used to be forbidden, but we have not heard any breakage
- report, and they are assumed to be safe.
+ . since late 2021 with 44ba10d6, we have had variables declared in
+ the for loop "for (int i = 0; i < 10; i++)".
- Variables have to be declared at the beginning of the block, before
the first statement (i.e. -Wdeclaration-after-statement).
- - Declaring a variable in the for loop "for (int i = 0; i < 10; i++)"
- is still not allowed in this codebase. We are in the process of
- allowing it by waiting to see that 44ba10d6 (revision: use C99
- declaration of variable in for() loop, 2021-11-14) does not get
- complaints. Let's revisit this around November 2022.
-
- NULL pointers shall be written as NULL, not as 0.
- When declaring pointers, the star sides with the variable