diff mbox

[v3] CODING_STYLE: Section about mixed declarations

Message ID 1395080791-18640-1-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost March 17, 2014, 6:26 p.m. UTC
We had an unwritten rule about declarations having to be at beginning of
blocks. Make it a written rule.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
Changes v3:
 * Wrap long lines

Changes v2:
 * s/be at beginning/be at the beginning/
---
 CODING_STYLE | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Peter Maydell March 17, 2014, 6:28 p.m. UTC | #1
On 17 March 2014 18:26, Eduardo Habkost <ehabkost@redhat.com> wrote:
> We had an unwritten rule about declarations having to be at beginning of
> blocks. Make it a written rule.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> Reviewed-by: Stefan Weil <sw@weilnetz.de>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
Michael Tokarev March 20, 2014, 3:59 p.m. UTC | #2
17.03.2014 22:26, Eduardo Habkost wrote:
> We had an unwritten rule about declarations having to be at beginning of
> blocks. Make it a written rule.

Thanks, applied to -trivial.

/mjt
Fabien Chouteau March 21, 2014, 6:04 p.m. UTC | #3
On 03/17/2014 07:26 PM, Eduardo Habkost wrote:
> We had an unwritten rule about declarations having to be at beginning of
> blocks. Make it a written rule.
> 

Hello Eduardo,

Is it possible to check this rule in script/checkpatch.pl? (or is it already?)

Regards,
Eduardo Habkost March 21, 2014, 6:17 p.m. UTC | #4
On Fri, Mar 21, 2014 at 07:04:08PM +0100, Fabien Chouteau wrote:
> On 03/17/2014 07:26 PM, Eduardo Habkost wrote:
> > We had an unwritten rule about declarations having to be at beginning of
> > blocks. Make it a written rule.
> > 
> 
> Hello Eduardo,
> 
> Is it possible to check this rule in script/checkpatch.pl? (or is it already?)

checkpatch.pl doesn't check it, currently. It is possible to check it,
if somebody writes the code to do that.
diff mbox

Patch

diff --git a/CODING_STYLE b/CODING_STYLE
index dcbce28..4280945 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -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.