From dc8e2b474a8eefc5ce34a13a69d16b98ac96217b Mon Sep 17 00:00:00 2001 From: Pekka Pessi Date: Fri, 3 Dec 2010 11:05:28 +0200 Subject: coding-style M14: parenthesis around sizeof arg --- doc/coding-style.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc/coding-style.txt') diff --git a/doc/coding-style.txt b/doc/coding-style.txt index 9dfdc09c..9d7131de 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -230,6 +230,20 @@ array = g_try_new0(int, 20); if (array == NULL) // Correct return; + +M14: Always use parenthesis with sizeof +======================================= +The expression argument to the sizeof operator should always be in +parenthesis, too. + +Example: +1) +memset(stuff, 0, sizeof(*stuff)); + +2) +memset(stuff, 0, sizeof *stuff); // Wrong + + O1: Shorten the name ==================== Better to use abbreviation, rather than full name, to name a variable, -- cgit v1.2.3