[Libreoffice-commits] core.git: Silence some conversion warnings

Stephan Bergmann sbergman at redhat.com
Mon Aug 24 02:11:38 PDT 2015


[putting the ML back into the loop]

On 08/24/2015 10:56 AM, Matteo Casalin wrote:
> 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.

So you're actually finding problems with that?  Good to know---probably 
makes the resulting increase in noise more tolerable. ;)

Anyway, if any of those "obvious" casts are not actually needed by your 
toolchain to silence warnings, then yes, might be good if you just 
removed those again.



More information about the LibreOffice mailing list