svn commit: r351364 - in head/sys: crypto/blowfish crypto/chacha20 crypto/des opencrypto

Warner Losh imp at bsdimp.com
Fri Aug 23 22:05:39 UTC 2019


On Fri, Aug 23, 2019 at 12:26 PM Conrad Meyer <cem at freebsd.org> wrote:

> At expected peril of wading into a thread >4 emails deep,
>
> @Warner, modern GCC reports a similar warning; it just doesn't become
> an error (at least in CI?).  I'm not sure of the mechanism.  Maybe
> CI-specific?  Old GCC didn't have a -Wno-error for -Wcast-qual, so
> -Wcast-qual + -Werror there produced an error; that's why
> $NO_WCAST_QUAL in conf/kern.mk is defined to -Wno-cast-qual for old
> GCC but -Wno-error=cast-qual for newer compilers.  That said, this
> file does not appear to be compiled with ${NO_WCAST_QUAL} either way.
>

Yea. I'm unsure. It's an odd warning, and an odd way to get around it. In
general, nobody cares about gcc 4.2.1, so pinning implementing that belief
to this specific bug may have been unwise. I just assumed newer versions
wouldn't warn on this, but I saw on IRC that the types are stupidly
different...


> @Bjoern,
>
> So... why does GCC warn about this? key is const uint8_t*.  The cast
> is to const des_cblock *.  I think the problem is that des_cblock is
> defined as 'unsigned char [8]', so a 'const des cblock *' is actually
> a 'const unsigned char**'?  So... I think basically the entire des
> subsystem may be accidentally using the wrong pointer level
> throughout?  The constify change just exposes that because correct
> const-preserving cast of 'const foo*' to 'foo**' would be 'foo * const
> *' (if I'm understanding this correctly).
>
> Maybe one more reason to excise des from the tree.


Ha! No comment :)

Warner


> Best,
> Conrad
>
>
> On Fri, Aug 23, 2019 at 9:59 AM Bjoern A. Zeeb <bz at freebsd.org> wrote:
> >
> > On 23 Aug 2019, at 16:48, Warner Losh wrote:
> > > There's a lot of -Wno-error and -Wno-error=XXX sprinkled in our build
> > > for
> > > gcc 4.2.1 today, so we see the warnings but aren't stopped by them. My
> > > changes take a big hammer and add a global -Wno-error to CFLAGS last
> > > to
> > > make this the behavior on gcc 4.2.1 platforms.
> >
> >
> > Yes, but that didn’t answer my questions.  It doesn’t help to try to
> > avoid undefined C behaviour.
> >
> > That jenkins build seems to use the toolchain from ports and with that
> > gcc 6.4.0.
> >
> > We see the same warning but it didn’t error as it seems to have done
> > for other architectures with the in-tree gcc with the same warnings:
> >
> > In file included from /workspace/src/sys/opencrypto/xform.c:94:0:
> > /workspace/src/sys/opencrypto/xform_des1.c: In function 'des1_setkey':
> > /workspace/src/sys/opencrypto/xform_des1.c:102:15: warning: cast
> > discards 'const' qualifier from pointer target type [-Wcast-qual]
> >     des_set_key((const des_cblock *) key, p[0]);
> >                 ^
> > In file included from /workspace/src/sys/opencrypto/xform.c:95:0:
> > /workspace/src/sys/opencrypto/xform_des3.c: In function 'des3_setkey':
> > /workspace/src/sys/opencrypto/xform_des3.c:103:15: warning: cast
> > discards 'const' qualifier from pointer target type [-Wcast-qual]
> >     des_set_key((const des_cblock *)(key +  0), p[0]);
> >                 ^
> > /workspace/src/sys/opencrypto/xform_des3.c:104:15: warning: cast
> > discards 'const' qualifier from pointer target type [-Wcast-qual]
> >     des_set_key((const des_cblock *)(key +  8), p[1]);
> >                 ^
> > /workspace/src/sys/opencrypto/xform_des3.c:105:15: warning: cast
> > discards 'const' qualifier from pointer target type [-Wcast-qual]
> >     des_set_key((const des_cblock *)(key + 16), p[2]);
> >                 ^
> > --
> >
> >
> >
> > To me this means that we treat different versions of compilers (in-tree
> > and out-of-tree, gcc vs. clang) too different.
> >
> > If two versions of gcc (before your commit) gave the same warning I
> > would have expected them to equally fail and not one fail and one pass?
> >
> > My question was:  why was that the case?
> >
> > /bz
> >
>


More information about the svn-src-all mailing list