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

This is a discussion on Re: [CVS] OpenSSL: openssl/crypto/x509/ x509_att.c - Openssl ; 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)) ...

+ Reply to Thread
Results 1 to 3 of 3

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

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

    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 majordomo@openssl.org


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

    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 majordomo@openssl.org


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

    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 majordomo@openssl.org


+ Reply to Thread