PVS: V629 Consider inspecting the 'col.red() << 24' expression. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type.

This commit is contained in:
wmayer
2019-02-17 22:27:00 +01:00
parent 2bb5797568
commit f0320d954a
5 changed files with 71 additions and 59 deletions

View File

@@ -273,9 +273,11 @@ void TextEditor::highlightCurrentLine()
if (!isReadOnly()) {
QTextEdit::ExtraSelection selection;
QColor lineColor = d->colormap[QLatin1String("Current line highlight")];
unsigned long col = (lineColor.red() << 24) | (lineColor.green() << 16) | (lineColor.blue() << 8);
unsigned int col = (lineColor.red() << 24) | (lineColor.green() << 16) | (lineColor.blue() << 8);
ParameterGrp::handle hPrefGrp = getWindowParameter();
col = hPrefGrp->GetUnsigned( "Current line highlight", col);
unsigned long value = static_cast<unsigned long>(col);
value = hPrefGrp->GetUnsigned( "Current line highlight", value);
col = static_cast<unsigned int>(value);
lineColor.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff);
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
@@ -434,8 +436,10 @@ void TextEditor::OnChange(Base::Subject<const char*> &rCaller,const char* sReaso
QMap<QString, QColor>::ConstIterator it = d->colormap.find(QString::fromLatin1(sReason));
if (it != d->colormap.end()) {
QColor color = it.value();
unsigned long col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8);
col = hPrefGrp->GetUnsigned( sReason, col);
unsigned int col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8);
unsigned long value = static_cast<unsigned long>(col);
value = hPrefGrp->GetUnsigned(sReason, value);
col = static_cast<unsigned int>(value);
color.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff);
if (this->highlighter)
this->highlighter->setColor(QLatin1String(sReason), color);