[Libreoffice-commits] core.git: Silence some conversion warnings
Matteo Casalin
matteo.casalin at yahoo.com
Mon Aug 24 01:59:05 PDT 2015
Hi
On Mon, 24 Aug 2015 10:37:38 +0200
Stephan Bergmann <sbergman at redhat.com> wrote:
> On 08/21/2015 10:30 PM, Matteo Casalin wrote:
> > commit eb4cbea657b9038c488f1b1bcf5107cc226a6681
> > Author: Matteo Casalin <matteo.casalin at yahoo.com>
> > Date: Sun Aug 16 16:32:13 2015 +0200
> >
> > Silence some conversion warnings
> >
> > Change-Id: I676ed010576f3a24b193ffc6c28a319bcc5ac968
> >
> [...]
> > diff --git a/store/source/storbase.hxx b/store/source/storbase.hxx
> > index 395870f..78a51a1 100644
> > --- a/store/source/storbase.hxx
> > +++ b/store/source/storbase.hxx
> > @@ -512,9 +512,9 @@ struct PageData
> > void guard (sal_uInt32 nAddr)
> > {
> > sal_uInt32 nCRC32 = 0;
> > - nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
> > + nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, static_cast<sal_uInt32>(sizeof(sal_uInt32)));
>
> What compiler/switch is it that warns there? It does not look like that
> particular compiler/switch is very useful. sizeof(sal_uInt32) is a
> known, small integer at compile time. It should be apparent to both the
> compiler and humans that it fits into the sal_uInt32 argument to
> rtl_crc32 without needing the static_cast noise.
That's GCC -Wconversion, which I'm using to chase harmful downcasts (e.g. sal_Int32 to sal_uInt16 for OUString length, there are still some of them here and there). The point is that some of these downcasts, although safe in themselves, introduce a lot of noise in the logs and make the real issues difficult to detect.
If I remember correctly in this case the warning was probably only in the result of "theSize - sizeof(G)" some lines below, I just casted both call places for simmetry. If that's undesired I'll revert the cast for the "sizeof(sal_uInt32)" calls.
Kind regards
Matteo
More information about the LibreOffice
mailing list