Re: [CVS] OpenSSL: openssl/crypto/x509/ x509_att.c

2008-06-02 Thread Ben Laurie

Dr. Stephen Henson wrote:

  - if (len == -1)
  + if ((len == -1)  !(attrtype  MBSTRING_FLAG))


I do wish you wouldn't use these extra brackets around comparison operators.

if (len == -1  !(attrtype  MBSTRING_FLAG))

works just fine and is consistent with most of the rest of the code, and 
the rest of the world.


--
http://www.apache-ssl.org/ben.html   http://www.links.org/

There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit. - Robert Woodruff
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: [CVS] OpenSSL: openssl/crypto/x509/ x509_att.c

2008-06-02 Thread Geoff Thorpe
On Friday 30 May 2008 09:52:40 Ben Laurie wrote:
 Dr. Stephen Henson wrote:
- if (len == -1)
+ if ((len == -1)  !(attrtype  MBSTRING_FLAG))

 I do wish you wouldn't use these extra brackets around comparison
 operators.

   if (len == -1  !(attrtype  MBSTRING_FLAG))

 works just fine and is consistent with most of the rest of the code, and
 the rest of the world.

I find Steve's version more readable. The object of the exercise is not to 
confront the reader with code that reminds them what the precedence of C 
operators are. Nor is it to require the reader to know those operators so 
well that they can spot code that looks right but is in fact wrong.

Cheers,
Geoff
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: [CVS] OpenSSL: openssl/crypto/x509/ x509_att.c

2008-06-02 Thread Michael Sierchio

Geoff Thorpe wrote:


On Friday 30 May 2008 09:52:40 Ben Laurie wrote:



Dr. Stephen Henson wrote:



I do wish you wouldn't use these extra brackets around comparison
operators.

if (len == -1  !(attrtype  MBSTRING_FLAG))

works just fine and is consistent with most of the rest of the code, and
the rest of the world.


I find Steve's version more readable.


Agreed.  Cleverness is not a virtue here, unless this is a programming
contest.  Very few programmers remember that , ^, |,  and || have
different precedence (and in the order in which I enumerated them)
and which ones associate left-to-right versus right-to-left.

When two expressions evaluate to the same value, a useful question to
ask is: which version reduces the cognitive load on the reader by
reducing ambiguity or error?

- M
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   [EMAIL PROTECTED]