[PATCH] Refactoring based on cppcheck suggestions

Richard Kimberly Heck rikiheck at lyx.org
Mon Oct 5 15:30:58 UTC 2020


On 10/5/20 7:03 AM, Yuriy Skalko wrote:
>> What happens if size_t numberofcells is 0 and cell is also 0? What is 0
>> - 1 for an unsigned int? Maybe numberofcells can't be 0, but still it
>> seems a bit confusing. I'd suggest:
>>
>>     return cell + 1 >= numberofcells;
>>
>> instead.
>>
>> Riki
> I assume that if numberofcells is 0 there cannot be 0-th cell, but it
> still worth to change the code. 

It seems simpler, anyway, yes.


> Another question is why to bother with
> unsigned's usage at all? In my experience unsigned types are only useful
> for flag values when definitely will be no arithmetic on such values. Qt
> also try to minimize usage of unsigned types.
>
> As I ran static analyzers on LyX code, there are many warnings on
> implicit signed-unsigned conversions in expressions.

What José said.

Riki




More information about the lyx-devel mailing list