From 78731463d6633281098d0dc25bac82a6d3f8eced Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Wed, 19 Sep 2018 15:22:26 -0400 Subject: [PATCH] replace old-style cast with static_cast --- lib/ColorScheme.cpp | 6 +++--- lib/History.cpp | 8 ++++---- lib/TerminalDisplay.cpp | 2 +- lib/Vt102Emulation.cpp | 2 +- lib/kptydevice.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ColorScheme.cpp b/lib/ColorScheme.cpp index 12ce19fd..e689408d 100644 --- a/lib/ColorScheme.cpp +++ b/lib/ColorScheme.cpp @@ -417,9 +417,9 @@ void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, co // if one of the keys already exists if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") ) { - configGroup.writeEntry("MaxRandomHue",(int)random.hue); - configGroup.writeEntry("MaxRandomValue",(int)random.value); - configGroup.writeEntry("MaxRandomSaturation",(int)random.saturation); + configGroup.writeEntry("MaxRandomHue",static_cast(random.hue)); + configGroup.writeEntry("MaxRandomValue",static_cast(random.value)); + configGroup.writeEntry("MaxRandomSaturation",static_cast(random.saturation)); } } #endif diff --git a/lib/History.cpp b/lib/History.cpp index 23be62ec..10759441 100644 --- a/lib/History.cpp +++ b/lib/History.cpp @@ -385,12 +385,12 @@ void HistoryScrollBuffer::setMaxNbLines(unsigned int lineCount) HistoryLine* oldBuffer = _historyBuffer; HistoryLine* newBuffer = new HistoryLine[lineCount]; - for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ ) + for ( int i = 0 ; i < qMin(_usedLines,static_cast(lineCount)) ; i++ ) { newBuffer[i] = oldBuffer[bufferIndex(i)]; } - _usedLines = qMin(_usedLines,(int)lineCount); + _usedLines = qMin(_usedLines,static_cast(lineCount)); _maxLineCount = lineCount; _head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1; @@ -770,7 +770,7 @@ void CompactHistoryScroll::setMaxNbLines ( unsigned int lineCount ) { _maxLineCount = lineCount; - while (lines.size() > (int) lineCount) { + while (lines.size() > static_cast(lineCount)) { delete lines.takeAt(0); } //kDebug() << "set max lines to: " << _maxLineCount; @@ -872,7 +872,7 @@ HistoryScroll* HistoryTypeBuffer::scroll(HistoryScroll *old) const HistoryScroll *newScroll = new HistoryScrollBuffer(m_nbLines); int lines = old->getLines(); int startLine = 0; - if (lines > (int) m_nbLines) + if (lines > static_cast(m_nbLines)) startLine = lines - m_nbLines; Character line[LINE_SIZE]; diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index c46c3c88..f0783735 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -226,7 +226,7 @@ void TerminalDisplay::fontChange(const QFont&) // "Base character width on widest ASCII character. This prevents too wide // characters in the presence of double wide (e.g. Japanese) characters." // Get the width from representative normal width characters - _fontWidth = qRound((double)fm.horizontalAdvance(QLatin1String(REPCHAR))/(double)qstrlen(REPCHAR)); + _fontWidth = qRound(static_cast(fm.horizontalAdvance(QLatin1String(REPCHAR)))/static_cast(qstrlen(REPCHAR))); _fixedFont = true; diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 4d5145c4..e74f8821 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -154,7 +154,7 @@ void Vt102Emulation::reset() */ -#define TY_CONSTRUCT(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) +#define TY_CONSTRUCT(T,A,N) ( (((static_cast(N)) & 0xffff) << 16) | (((static_cast(A)) & 0xff) << 8) | ((static_cast(T)) & 0xff) ) #define TY_CHR( ) TY_CONSTRUCT(0,0,0) #define TY_CTL(A ) TY_CONSTRUCT(1,A,0) diff --git a/lib/kptydevice.cpp b/lib/kptydevice.cpp index 9af1545d..b101d12b 100644 --- a/lib/kptydevice.cpp +++ b/lib/kptydevice.cpp @@ -400,14 +400,14 @@ bool KPtyDevice::isSuspended() const qint64 KPtyDevice::readData(char *data, qint64 maxlen) { Q_D(KPtyDevice); - return d->readBuffer.read(data, (int)qMin(maxlen, KMAXINT)); + return d->readBuffer.read(data, static_cast(qMin(maxlen, KMAXINT))); } // protected qint64 KPtyDevice::readLineData(char *data, qint64 maxlen) { Q_D(KPtyDevice); - return d->readBuffer.readLine(data, (int)qMin(maxlen, KMAXINT)); + return d->readBuffer.readLine(data, static_cast(qMin(maxlen, KMAXINT))); } // protected