From de66975a85008d39ca9d877ab488d0091ef3cfd5 Mon Sep 17 00:00:00 2001 From: LordGrey <48840279+Lord-Grey@users.noreply.github.com> Date: Sat, 28 Dec 2024 19:55:07 +0100 Subject: [PATCH] Address compile warnings --- libsrc/api/JsonAPI.cpp | 8 ++++++-- libsrc/leddevice/dev_ftdi/ProviderFtdi.cpp | 21 ++++++++++----------- libsrc/python/PythonProgram.cpp | 2 +- libsrc/utils/ImageResampler.cpp | 11 +++++------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libsrc/api/JsonAPI.cpp b/libsrc/api/JsonAPI.cpp index ac5fcdc1..3d4daaba 100644 --- a/libsrc/api/JsonAPI.cpp +++ b/libsrc/api/JsonAPI.cpp @@ -922,13 +922,17 @@ void JsonAPI::handleSchemaGetCommand(const QJsonObject& /*message*/, const JsonA // Add infor about the type of setting elements QJsonObject settingTypes; QJsonArray globalSettingTypes; - for (const QString &type : SettingsTable().getGlobalSettingTypes()) { + + SettingsTable settingsTable; + for (const QString &type : settingsTable.getGlobalSettingTypes()) + { globalSettingTypes.append(type); } settingTypes.insert("globalProperties", globalSettingTypes); QJsonArray instanceSettingTypes; - for (const QString &type : SettingsTable().getInstanceSettingTypes()) { + for (const QString &type : settingsTable.getInstanceSettingTypes()) + { instanceSettingTypes.append(type); } settingTypes.insert("instanceProperties", instanceSettingTypes); diff --git a/libsrc/leddevice/dev_ftdi/ProviderFtdi.cpp b/libsrc/leddevice/dev_ftdi/ProviderFtdi.cpp index ce168821..407d9d0c 100644 --- a/libsrc/leddevice/dev_ftdi/ProviderFtdi.cpp +++ b/libsrc/leddevice/dev_ftdi/ProviderFtdi.cpp @@ -67,12 +67,12 @@ int ProviderFtdi::open() Debug(_log, "Opening FTDI device=%s", QSTRING_CSTR(_deviceName)); - FTDI_CHECK_RESULT((rc = ftdi_usb_open_string(_ftdic, QSTRING_CSTR(_deviceName))) < 0); + FTDI_CHECK_RESULT((rc = ftdi_usb_open_string(_ftdic, QSTRING_CSTR(_deviceName))) < 0) /* doing this disable resets things if they were in a bad state */ - FTDI_CHECK_RESULT((rc = ftdi_disable_bitbang(_ftdic)) < 0); - FTDI_CHECK_RESULT((rc = ftdi_setflowctrl(_ftdic, SIO_DISABLE_FLOW_CTRL)) < 0); - FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET)) < 0); - FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0xff, BITMODE_MPSSE)) < 0); + FTDI_CHECK_RESULT((rc = ftdi_disable_bitbang(_ftdic)) < 0) + FTDI_CHECK_RESULT((rc = ftdi_setflowctrl(_ftdic, SIO_DISABLE_FLOW_CTRL)) < 0) + FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET)) < 0) + FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0xff, BITMODE_MPSSE)) < 0) double reference_clock = 60e6; int divisor = (reference_clock / 2 / _baudRate_Hz) - 1; @@ -86,7 +86,7 @@ int ProviderFtdi::open() pinDirection }; - FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size()); + FTDI_CHECK_RESULT(static_cast(rc = ftdi_write_data(_ftdic, buf.data(), static_cast(buf.size()))) != buf.size()) _isDeviceReady = true; return rc; @@ -134,7 +134,7 @@ int ProviderFtdi::writeBytes(const qint64 size, const uint8_t *data) // SET_BITS_LOW takes 2 arguments, so we're inserting data in -3 position from the end buf.insert(buf.end() - 3, &data[0], &data[size]); - FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size()); + FTDI_CHECK_RESULT(static_cast(rc = ftdi_write_data(_ftdic, buf.data(), static_cast(buf.size()))) != buf.size()) return rc; } @@ -152,7 +152,7 @@ QJsonObject ProviderFtdi::discover(const QJsonObject & /*params*/) struct ftdi_device_list *curdev = devlist; QMap deviceIndexes; - while (curdev) + while (curdev != nullptr) { libusb_device_descriptor desc; int rc = libusb_get_device_descriptor(curdev->dev, &desc); @@ -161,8 +161,7 @@ QJsonObject ProviderFtdi::discover(const QJsonObject & /*params*/) QString vendorIdentifier = QString("0x%1").arg(desc.idVendor, 4, 16, QChar{'0'}); QString productIdentifier = QString("0x%1").arg(desc.idProduct, 4, 16, QChar{'0'}); QString vendorAndProduct = QString("%1:%2") - .arg(vendorIdentifier) - .arg(productIdentifier); + .arg(vendorIdentifier,productIdentifier); uint8_t deviceIndex = deviceIndexes.value(vendorAndProduct, 0); char serial_string[128] = {0}; @@ -174,7 +173,7 @@ QJsonObject ProviderFtdi::discover(const QJsonObject & /*params*/) QString ftdiOpenString; if(!serialNumber.isEmpty()) { - ftdiOpenString = QString("s:%1:%2").arg(vendorAndProduct).arg(serialNumber); + ftdiOpenString = QString("s:%1:%2").arg(vendorAndProduct, serialNumber); } else { diff --git a/libsrc/python/PythonProgram.cpp b/libsrc/python/PythonProgram.cpp index 6f0b08c9..942187bc 100644 --- a/libsrc/python/PythonProgram.cpp +++ b/libsrc/python/PythonProgram.cpp @@ -25,7 +25,7 @@ PythonProgram::PythonProgram(const QString& name, Logger* log) : PyEval_RestoreThread(mainThreadState); _tstate = Py_NewInterpreter(); #else - PyThreadState* prev = PyThreadState_Swap(NULL); + PyThreadState_Swap(NULL); // Create a new interpreter configuration object PyInterpreterConfig config{}; diff --git a/libsrc/utils/ImageResampler.cpp b/libsrc/utils/ImageResampler.cpp index b205e0d3..d36beb10 100644 --- a/libsrc/utils/ImageResampler.cpp +++ b/libsrc/utils/ImageResampler.cpp @@ -50,16 +50,15 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i outputImage.resize(outputWidth, outputHeight); - int xDestStart, xDestEnd; - int yDestStart, yDestEnd; + int xDestStart {0}; + int xDestEnd = {outputWidth-1}; + int yDestStart = {0}; + int yDestEnd = {outputWidth-1}; switch (_flipMode) { case FlipMode::NO_CHANGE: - xDestStart = 0; - xDestEnd = outputWidth-1; - yDestStart = 0; - yDestEnd = outputHeight-1; + //use the initalized values break; case FlipMode::HORIZONTAL: xDestStart = 0;