Skip to contentSkip to conversation

CODING_STYLE: Section about mixed declarations

PATCH RESEND Superseded Eduardo Habkost 2 participants 2 messages Feb 26, 2014 – Feb 27, 2014

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 CODING_STYLE: Section about mixed declarations

We had an unwritten rule about declarations having to be at beginning of blocks. Make it a written rule.

---
Changes v2:
* s/be at beginning/be at the beginning/

---
 CODING_STYLE | 7 +++++++
 1 file changed, 7 insertions(+)
CODING_STYLE +7 -0
index dcbce28..efa5cc3 100644
@@ -84,3 +84,10 @@ and clarity it comes on a line by itself:
 Rationale: a consistent (except for functions...) bracing style reduces
 ambiguity and avoids needless churn when lines are added or removed.
 Furthermore, it is the QEMU coding style.
+
+5. Declarations
+
+Mixed declarations (interleaving statements and declarations within blocks) are
+not allowed; declarations should be at the beginning of blocks.  In other words,
+the code should not generate warnings if using GCC's
+-Wdeclaration-after-statement option.
Signature · 1 line
1.8.5.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Eduardo Habkost

We had an unwritten rule about declarations having to be at beginning of blocks. Make it a written rule.

---
Changes v2:
* s/be at beginning/be at the beginning/

---
 CODING_STYLE | 7 +++++++
 1 file changed, 7 insertions(+)
CODING_STYLE +0 -0
index dcbce28..efa5cc3 100644

CODING_STYLE and clarity it comes on a line by itself: · line 93

Quoted 10 lines
CODING_STYLE +7 -0
@@ -84,3 +84,10 @@ and clarity it comes on a line by itself:
 Rationale: a consistent (except for functions...) bracing style reduces
 ambiguity and avoids needless churn when lines are added or removed.
 Furthermore, it is the QEMU coding style.
+
+5. Declarations
+
+Mixed declarations (interleaving statements and declarations within blocks) are
+not allowed; declarations should be at the beginning of blocks.  In other words,
+the code should not generate warnings if using GCC's
+-Wdeclaration-after-statement option.

Long lines. We'll live.

I'd like to see either arguments or a commit. For good measure: