[PATCH] Refactoring based on cppcheck suggestions

Yuriy Skalko yuriy.skalko at gmail.com
Mon Oct 5 11:03:25 UTC 2020


> 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. 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.


Yuriy


More information about the lyx-devel mailing list