Re: [CVS] OpenSSL: openssl/apps/ ca.c - Openssl

This is a discussion on Re: [CVS] OpenSSL: openssl/apps/ ca.c - Openssl ; Dr. Stephen Henson wrote: > OpenSSL CVS Repository > http://cvs.openssl.org/ > __________________________________________________ __________________________ > > Server: cvs.openssl.org Name: Dr. Stephen Henson > Root: /v/openssl/cvs Email: steve@openssl.org > Module: openssl Date: 31-May-2008 21:28:58 > Branch: HEAD Handle: 2008053120285700 > > Modified ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Re: [CVS] OpenSSL: openssl/apps/ ca.c

  1. Re: [CVS] OpenSSL: openssl/apps/ ca.c

    Dr. Stephen Henson wrote:
    > OpenSSL CVS Repository
    > http://cvs.openssl.org/
    > __________________________________________________ __________________________
    >
    > Server: cvs.openssl.org Name: Dr. Stephen Henson
    > Root: /v/openssl/cvs Email: steve@openssl.org
    > Module: openssl Date: 31-May-2008 21:28:58
    > Branch: HEAD Handle: 2008053120285700
    >
    > Modified files:
    > openssl/apps ca.c
    >
    > Log:
    > Stop const mismatch warning.


    I do wish you'd find ways to fix these that don't involve casts!

    >
    > Summary:
    > Revision Changes Path
    > 1.160 +1 -1 openssl/apps/ca.c
    > __________________________________________________ __________________________
    >
    > patch -p0 <<'@@ .'
    > Index: openssl/apps/ca.c
    > ================================================== ==========================
    > $ cvs diff -u -r1.159 -r1.160 ca.c
    > --- openssl/apps/ca.c 26 May 2008 11:24:18 -0000 1.159
    > +++ openssl/apps/ca.c 31 May 2008 19:28:57 -0000 1.160
    > @@ -2481,7 +2481,7 @@
    > goto err;
    >
    > }
    > - else if (index_name_cmp(row,rrow))
    > + else if (index_name_cmp((const CSTRING *)row,(const CSTRING *)rrow))
    > {
    > BIO_printf(bio_err,"ERROR:name does not match %s\n",
    > row[DB_name]);
    > @@ .
    > __________________________________________________ ____________________
    > OpenSSL Project http://www.openssl.org
    > CVS Repository Commit List openssl-cvs@openssl.org
    > Automated List Manager majordomo@openssl.org
    >
    >



    --
    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/apps/ ca.c

    On Sun, Jun 01, 2008, Ben Laurie wrote:

    > Dr. Stephen Henson wrote:
    >> OpenSSL CVS Repository
    >> http://cvs.openssl.org/
    >>
    >> __________________________________________________ __________________________
    >> Server: cvs.openssl.org Name: Dr. Stephen Henson
    >> Root: /v/openssl/cvs Email: steve@openssl.org
    >> Module: openssl Date: 31-May-2008 21:28:58
    >> Branch: HEAD Handle: 2008053120285700
    >> Modified files:
    >> openssl/apps ca.c
    >> Log:
    >> Stop const mismatch warning.

    >
    > I do wish you'd find ways to fix these that don't involve casts!
    >


    Well I'm open to suggestions on this one...

    It's a "feature" of C that if you do...

    const something * const *foo;
    something **bar;

    foo = bar;

    you get a warning about different const types. This bit in the ASN1 code where
    what used to be:

    char **p;

    was changed to the more correct:

    const char * const *p;

    and produces warnings in code which uses the previous form.

    Steve.
    --
    Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
    OpenSSL project core developer and freelance consultant.
    Homepage: http://www.drh-consultancy.demon.co.uk
    __________________________________________________ ____________________
    OpenSSL Project http://www.openssl.org
    Development Mailing List openssl-dev@openssl.org
    Automated List Manager majordomo@openssl.org


  3. Re: [CVS] OpenSSL: openssl/apps/ ca.c

    On Mon, Jun 2, 2008 at 12:47 PM, Dr. Stephen Henson wrote:
    > On Sun, Jun 01, 2008, Ben Laurie wrote:


    >>> Stop const mismatch warning.


    >>> - else if (index_name_cmp(row,rrow))
    >>> + else if (index_name_cmp((const CSTRING *)row,(const CSTRING *)rrow))


    >> I do wish you'd find ways to fix these that don't involve casts!


    > Well I'm open to suggestions on this one...
    >
    > It's a "feature" of C that if you do...
    >
    > const something * const *foo;
    > something **bar;
    >
    > foo = bar;
    >
    > you get a warning about different const types. This bit in the ASN1 code where
    > what used to be:
    >
    > char **p;
    >
    > was changed to the more correct:
    >
    > const char * const *p;
    >
    > and produces warnings in code which uses the previous form.


    You can create a type-safe macro that does the cast for you -- see
    examples in Ben's recent code.

    An expression such as

    (1 ? (p) : (char **)NULL)

    in the macro's definition should ensure that using the macro will
    cause a warning if p isn't of the intended type. So just cast an
    expression like this to the properly constified type, within the
    macro. Then the cast is just in the macro definition where it can be
    more easily verified, rather than having casts directly in the code.

    Bodo
    __________________________________________________ ____________________
    OpenSSL Project http://www.openssl.org
    Development Mailing List openssl-dev@openssl.org
    Automated List Manager majordomo@openssl.org


  4. Re: [CVS] OpenSSL: openssl/apps/ ca.c

    Bodo Moeller wrote:
    > On Mon, Jun 2, 2008 at 12:47 PM, Dr. Stephen Henson wrote:
    >> On Sun, Jun 01, 2008, Ben Laurie wrote:

    >
    >>>> Stop const mismatch warning.

    >
    >>>> - else if (index_name_cmp(row,rrow))
    >>>> + else if (index_name_cmp((const CSTRING *)row,(const CSTRING *)rrow))

    >
    >>> I do wish you'd find ways to fix these that don't involve casts!

    >
    >> Well I'm open to suggestions on this one...
    >>
    >> It's a "feature" of C that if you do...
    >>
    >> const something * const *foo;
    >> something **bar;
    >>
    >> foo = bar;
    >>
    >> you get a warning about different const types. This bit in the ASN1 code where
    >> what used to be:
    >>
    >> char **p;
    >>
    >> was changed to the more correct:
    >>
    >> const char * const *p;
    >>
    >> and produces warnings in code which uses the previous form.

    >
    > You can create a type-safe macro that does the cast for you -- see
    > examples in Ben's recent code.
    >
    > An expression such as
    >
    > (1 ? (p) : (char **)NULL)
    >
    > in the macro's definition should ensure that using the macro will
    > cause a warning if p isn't of the intended type. So just cast an
    > expression like this to the properly constified type, within the
    > macro. Then the cast is just in the macro definition where it can be
    > more easily verified, rather than having casts directly in the code.


    Is that really the only way to avoid this?

    Anyone know what's behind the warning?

    --
    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


+ Reply to Thread