[openssl-commits] [web] master update

Rich Salz rsalz at openssl.org
Mon May 25 23:09:12 UTC 2015


The branch master has been updated
       via  f7dd814fc51f0d7968805efb5f0df4ffbe546ab3 (commit)
      from  24b6f7ec36449f7b39bb04df4626b292664654bc (commit)


- Log -----------------------------------------------------------------
commit f7dd814fc51f0d7968805efb5f0df4ffbe546ab3
Author: Rich Salz <rsalz at akamai.com>
Date:   Thu May 7 21:58:03 2015 -0400

    update for sizeof(*p) and use of !

-----------------------------------------------------------------------

Summary of changes:
 about/codingstyle.txt | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/about/codingstyle.txt b/about/codingstyle.txt
index d133709..1b22575 100644
--- a/about/codingstyle.txt
+++ b/about/codingstyle.txt
@@ -154,10 +154,13 @@ a function or keyword. Use a space after most keywords:
     if, switch, case, for, do, while, return
 
 Do not use a space after sizeof, typeof, alignof, or __attribute__.
-They look somewhat like functions and are usually used with parentheses
-in OpenSSL, although they are not required in the language:
+They look somewhat like functions and should have parentheses
+in OpenSSL, although they are not required by the language. For sizeof,
+use a variable when at all possible, to ensure that type changes are
+properly reflected:
+
+    SOMETYPE *p = OPENSSL_malloc(sizeof(*p) * num_of_elements);
 
-    s = sizeof(struct file);
 
 Do not add spaces around the inside of parenthesized expressions.
 This example is wrong:
@@ -537,6 +540,20 @@ should be used. This is more commonly referred to as C90. ISO/IEC 9899:1999
 used on and therefore should be avoided.
 
 
+                Chapter 21: Miscellaneous
+
+Do not use ! to check if a pointer is NULL, or to see if a str...cmp
+function found a match.  For example, these are wrong:
+
+    if (!(p = BN_new())) ...
+    if (!strcmp(a, "FOO")) ...
+
+Do this instead:
+
+    if ((p = BN_new()) == NULL)...
+    if (strcmp(a, "FOO") == 0) ...
+
+
                 Appendix A: References
 
 The C Programming Language, Second Edition


More information about the openssl-commits mailing list