[Libreoffice] [PUSHED] cppcheck cleanliness: duplicate expression
Stephan Bergmann
sbergman at redhat.com
Wed Sep 7 23:40:24 PDT 2011
On 09/08/2011 08:18 AM, Stephan Bergmann wrote:
> On 09/08/2011 01:44 AM, Eike Rathke wrote:
>> Hi Korrawit,
>>
>> On Wednesday, 2011-09-07 22:01:09 +0700, Korrawit Pruegsanusak wrote:
>>
>>> Attached patch will clear the cppcheck warning for duplicate
>>> expression on both sides of '<'.
>>
>> Yup, good catch!
>> http://cgit.freedesktop.org/libreoffice/core/commit/?id=a58ed493e572fef2c503bd329e924bb062ba9c96
>>
>>
>> Thanks
>> Eike
>
> Korrawit, Eike, did you check the context to verify that it should
> really read
>
> a.nChar1 == a.nChar2
>
> instead of
>
> a.nChar1 == b.nChar1
>
> in the second term of
>
>> (a.nChar1 < b.nChar1) || ((a.nChar1 == a.nChar2) && (a.nChar2 <
>> b.nChar2))
>
> ? Somehow, that expression still looks suspicious. (At least, it does
> not implement a lexicographical less-than relation. Not sure whether it
> should or not, however.)
Now actually looking at the context: Given that CmpKernData in
vcl/source/gdi/outdev3.cxx is (only) used as an argument to std::sort,
I'm pretty sure it must read (a.nChar1 == b.nChar1) to make that a true
strict weak ordering, as required by std::sort. Pushed as
<http://cgit.freedesktop.org/libreoffice/core/commit/?id=8b7978c822b11c53b4bd40bb0829e3ec205f1359>.
-Stephan
More information about the LibreOffice
mailing list