[OpenSSL-3.0LTS] TNF local patch - respect -Wcast-qual

Issue #379 wontfix
Takehiko NOZAKI repo owner created an issue

TNF don’t like cast (const type *) to (type *) directly, and they often enables -Wcast-qual with -Werror.

they defines __UNCONST macro in sys/cdefs.h:

const type *a;
type *b;
a = __UNCONST(a);

but in this patch, they dont use it for portability(and maybe its implementation is broken future 128bit pointer era), so use intptr_t like:

const type *a;
type *b;
a = (type *)(intptr_t)a;

Comments (5)

  1. Takehiko NOZAKI reporter

    in terms of C specification, cast const *type to type * is completely legal, but sometimes const qualifier is used for memory protection, see following examples taken from GCC’s manual:

      /* p is char ** value.  */
      const char **q = (const char **) p;
      /* Assignment of readonly string to const char * is OK.  */
      *q = "string";
      /* Now char** pointer points to read-only memory.  */
      **p = 'b';
    

    so -Wcast-qual may help to detect assignment of read-only location error.

    but TNF, they blindly uses __UNCONST macro and never checks these memories can really be writable.

    so they work hard, but they got nothing, it is only same result -Wno-cast-qual how idiot!(same as F*BSD, they do as same by __DECONST macro)

    O*BSD keeps avoid to use -Wcast-qual, it seems that they believe -Wcast-qual is harmful, i think.

  2. Takehiko NOZAKI reporter

    and OpenSSL’s coder is completely suck:

    I don't understand C anything at all, and I wrote const qualifier in the mood…

    this is why so many OpenSSL fork exists such as LibreSSL/BoringSSL.

  3. Log in to comment