Avoid 'conversion may change value' cases related to JobMan and several files
Avoid two warnings related to JobMan confirming the conversions to int
because:
- A non-Krusader function that is used (
setValue(int value)
) only accepts that type. - An existing
int percent()
function only returns anint
(and it doesn't need returning numbers bigger than 100).
Avoid 'conversion may change value' warnings in krcolorcache.cpp by removing a cast that was not needed.
Avoid 'conversion may change value' warnings in kr7zencryptionchecker.cpp,
confirming a conversion to __pid_t
because a non-Krusader function that is
used (kill (__pid_t __pid, int __sig)
) only accepts the aforementioned type.
Avoid two warnings in advancedfilter.cpp, confirming conversions to int
because a non-Krusader function that is used (setValue(int value)
) only
accepts that data type.
Avoid four 'conversion may change value' warnings in krquery.cpp, confirming the conversions to uint
because a non-Krusader function that is used (fromTime_t()
) does not accept data types that are bigger than uint
.
Avoid one 'conversion may change value' warning in krquery.cpp, confirming a conversion to int
because ─as it's stated in the documentation─ "qint64 QIODevice::read(char *data, qint64 maxSize)
Reads at most maxSize
bytes" and maxSize
is only 1440 in this case.
Avoid a 'conversion may change value' warning in splitter.cpp by means of separating an assignment.
Avoid three 'conversion may change value' warnings in splitter.cpp, confirming conversions to int
because:
- a non-Krusader function that is used (
setValue(int value)
) only accepts that data type and a percentage is not going to be bigger than 100; - a non-Krusader function that is used twice (
QByteArray(const char *data, int size)
) only acceptsint
arguments.
Avoid several 'conversion to double
may change value' warnings in splittergui.cpp by means of:
- confirming conversions to integer data types;
- using
long double
to store the results of operations, and later converting data todouble
because that is whatQDoubleSpinBox::setValue()
accepts; - confirming direct conversions to
double
, because no more precision is needed, anddouble
is whatQDoubleSpinBox::setValue()
accepts.
Avoid one 'conversion from double
to KIO::filesize_t
' warning in splittergui.cpp by means of confirming conversions to integer data types.
The warnings are:
/home/user/krusader/krusader/JobMan/krjob.h: In member function ‘int KrJob::percent() const’:
/home/user/krusader/krusader/JobMan/krjob.h:51:40: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
51 | int percent() const { return m_job ? m_job->percent() : 0; }
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/JobMan/jobman.cpp: In member function ‘void JobMenuAction::slotPercent(KJob*, long unsigned int)’:
/home/user/krusader/krusader/JobMan/jobman.cpp:89:79: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
89 | void slotPercent(KJob *, unsigned long percent) { m_progressBar->setValue(percent); }
| ^~~~~~~
/home/user/krusader/krusader/Panel/krcolorcache.cpp: In member function ‘void KrColorSettingsImpl::loadFromConfig()’:
/home/user/krusader/krusader/Panel/krcolorcache.cpp:155:48: warning: conversion from ‘long long int’ to ‘int’ may change value [-Wconversion]
155 | m_numValues[name] = group.readEntry(name, (long long)0);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/Archive/kr7zencryptionchecker.cpp: In member function ‘void Kr7zEncryptionChecker::receivedOutput()’:
/home/user/krusader/krusader/Archive/kr7zencryptionchecker.cpp:46:20: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘__pid_t’ {aka ‘int’} may change value [-Wconversion]
46 | ::kill(- processId(), SIGKILL); // kill the whole process group by giving the negative PID
| ^~~~~~~~~~~~~
/home/user/krusader/krusader/Filter/advancedfilter.cpp:553: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Filter/advancedfilter.cpp: In member function ‘virtual void AdvancedFilter::applySettings(const FilterSettings&)’:
/home/user/krusader/krusader/Filter/advancedfilter.cpp:553:39: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
553 | minSizeAmount->setValue(s.minSize.amount);
| ~~~~~~~~~~^~~~~~
/home/user/krusader/krusader/Filter/advancedfilter.cpp:557: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Filter/advancedfilter.cpp:557:39: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
557 | maxSizeAmount->setValue(s.maxSize.amount);
| ~~~~~~~~~~^~~~~~
/home/user/krusader/krusader/FileSystem/krquery.cpp:134: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
/home/user/krusader/krusader/FileSystem/krquery.cpp: In member function ‘void KrQuery::load(const KConfigGroup&)’:
/home/user/krusader/krusader/FileSystem/krquery.cpp:134:70: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
134 | cfg.readEntry("NewerThan", QDateTime::fromTime_t(newerThen).toString()))
| ^~~~~~~~~
/home/user/krusader/krusader/FileSystem/krquery.cpp:137: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
/home/user/krusader/krusader/FileSystem/krquery.cpp:137:70: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
137 | cfg.readEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString()))
| ^~~~~~~~~
/home/user/krusader/krusader/FileSystem/krquery.cpp:182: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
/home/user/krusader/krusader/FileSystem/krquery.cpp: In member function ‘void KrQuery::save(KConfigGroup)’:
/home/user/krusader/krusader/FileSystem/krquery.cpp:182:55: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
182 | cfg.writeEntry("NewerThan", QDateTime::fromTime_t(newerThen).toString());
| ^~~~~~~~~
/home/user/krusader/krusader/FileSystem/krquery.cpp:183: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
/home/user/krusader/krusader/FileSystem/krquery.cpp:183:55: warning: conversion from ‘time_t’ {aka ‘long int’} to ‘uint’ {aka ‘unsigned int’} may change value [-Wconversion]
183 | cfg.writeEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString());
| ^~~~~~~~~
/home/user/krusader/krusader/FileSystem/krquery.cpp:479: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/FileSystem/krquery.cpp: In member function ‘bool KrQuery::containsContent(const QString&) const’:
/home/user/krusader/krusader/FileSystem/krquery.cpp:479:28: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
479 | int bytes = qf.read(buffer, sizeof(buffer));
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/Splitter/splitter.cpp:62: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splitter.cpp: In member function ‘void Splitter::split(KIO::filesize_t)’:
/home/user/krusader/krusader/Splitter/splitter.cpp:62:31: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
62 | fileNumber = receivedSize = outputFileRemaining = 0;
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/Splitter/splitter.cpp:136: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splitter.cpp: In member function ‘void Splitter::splitReceivePercent(KJob*, long unsigned int)’:
/home/user/krusader/krusader/Splitter/splitter.cpp:136:14: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
136 | setValue(percent);
| ^~~~~~~
/home/user/krusader/krusader/Splitter/splitter.cpp:211: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splitter.cpp: In member function ‘void Splitter::splitDataSend(KIO::Job*, QByteArray&)’:
/home/user/krusader/krusader/Splitter/splitter.cpp:211:54: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
211 | byteArray = QByteArray(transferArray.data(), outputFileRemaining);
| ^~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/Splitter/splitter.cpp:213: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splitter.cpp:213:46: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘int’ may change value [-Wconversion]
213 | bufferLen - outputFileRemaining);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:159: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp: In member function ‘KIO::filesize_t SplitterGUI::getSplitSize()’:
/home/user/krusader/krusader/Splitter/splittergui.cpp:159:31: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
159 | return spinBox->value() * division;
| ^~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:159: warning: conversion from ‘double’ to ‘KIO::filesize_t’ {aka ‘long long unsigned int’} may change value [-Wfloat-conversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp:159:29: warning: conversion from ‘double’ to ‘KIO::filesize_t’ {aka ‘long long unsigned int’} may change value [-Wfloat-conversion]
159 | return spinBox->value() * division;
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:186: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp: In member function ‘virtual void SplitterGUI::sizeComboActivated(int)’:
/home/user/krusader/krusader/Splitter/splittergui.cpp:186:85: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
186 | value = (double)predefinedDevices()[deviceCombo->currentIndex()].capacity / division;
| ^~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:188: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp:188:45: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
188 | value = (double)(spinBox->value() * prevDivision) / division;
| ^~~~~~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:188: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp:188:61: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
188 | value = (double)(spinBox->value() * prevDivision) / division;
| ^~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:203: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp: In member function ‘virtual void SplitterGUI::predefinedComboActivated(int)’:
/home/user/krusader/krusader/Splitter/splittergui.cpp:203:46: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
203 | userDefinedSize = spinBox->value() * division; // remember user defined size
| ^~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:203: warning: conversion from ‘double’ to ‘KIO::filesize_t’ {aka ‘long long unsigned int’} may change value [-Wfloat-conversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp:203:44: warning: conversion from ‘double’ to ‘KIO::filesize_t’ {aka ‘long long unsigned int’} may change value [-Wfloat-conversion]
203 | userDefinedSize = spinBox->value() * division; // remember user defined size
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/user/krusader/krusader/Splitter/splittergui.cpp:227: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
/home/user/krusader/krusader/Splitter/splittergui.cpp:227:42: warning: conversion from ‘KIO::filesize_t’ {aka ‘long long unsigned int’} to ‘double’ may change value [-Wconversion]
227 | spinBox->setValue((double)capacity / division);
| ^~~~~~~~
TEST PLAN
The behavior of Krusader should not change after applying the proposed changes. Anyway, if anyone wants to perform some tests:
- Use F5 to copy a folder with big files, check that the progress percentage of the copy is correct.
- Go to "Settings > Configure Krusader... > Colors" and change the background color. Check that the result is the expected one.
- Enter a 7z encrypted archive. Note: One example is attached, the password of that archive is "Krusader". Check that a password is asked and that the files inside the archive are seen correctly.
- Go to "View > Custom" and choose a filter. Check that the filter is applied correctly.
- Press Ctrl+S, search for a file that has an 'a' inside. Check that the results are correct.
- Go to "File > Split File..." and split a big file, check that the percentages that are shown are correct, and that the resulting files can be correctly combined using "File > Combine Files...".