coding-style M14: parenthesis around sizeof arg
authorPekka Pessi <Pekka.Pessi@nokia.com>
Fri, 3 Dec 2010 09:05:28 +0000 (11:05 +0200)
committerAki Niemi <aki.niemi@nokia.com>
Fri, 3 Dec 2010 12:48:41 +0000 (14:48 +0200)
doc/coding-style.txt

index 9dfdc09..9d7131d 100644 (file)
@@ -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,