From 452e3413d5b24601c21ef9c558d8a5d25dfd0a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:32:08 +0200 Subject: [PATCH 01/13] Add static_cast() for the Qt size and index type when coming from std types --- src/library/dao/trackdao.cpp | 2 +- src/track/serato/beatgrid.cpp | 2 +- src/util/cache.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index 4fd20e20b4b..81d24e03445 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -1395,7 +1395,7 @@ TrackPointer TrackDAO::getTrackById(TrackId trackId) const { {"coverart_digest", nullptr}, {"coverart_hash", nullptr}, }; - constexpr int columnsCount = std::size(columns); + constexpr int columnsCount = static_cast(std::size(columns)); // Accessing the database is a time consuming operation that should not // be executed with a lock on the GlobalTrackCache. The GlobalTrackCache diff --git a/src/track/serato/beatgrid.cpp b/src/track/serato/beatgrid.cpp index 52e5ebd4488..faea3c8181f 100644 --- a/src/track/serato/beatgrid.cpp +++ b/src/track/serato/beatgrid.cpp @@ -458,7 +458,7 @@ void SeratoBeatGrid::setBeats(BeatsPointer pBeats, } } - nonTerminalMarkers.reserve(markers.size()); + nonTerminalMarkers.reserve(static_cast(markers.size())); std::transform(markers.cbegin(), markers.cend(), std::back_inserter(nonTerminalMarkers), diff --git a/src/util/cache.cpp b/src/util/cache.cpp index 21c699fb422..a5131b4af23 100644 --- a/src/util/cache.cpp +++ b/src/util/cache.cpp @@ -15,10 +15,10 @@ cache_key_t cacheKeyFromMessageDigest(const QByteArray& messageDigest) { // SP 800-107 // 5 Hash function Usage // 5.1 Truncated Message Digest - const size_t significantByteCount = math_min( - static_cast(messageDigest.size()), - sizeof(cache_key_t)); - for (size_t i = 0; i < significantByteCount; ++i) { + const int significantByteCount = math_min( + static_cast(messageDigest.size()), + static_cast(sizeof(cache_key_t))); + for (int i = 0; i < significantByteCount; ++i) { // Only 8 bits are relevant and we don't want the sign // extension of a (signed) char during the conversion. const cache_key_t nextByte = From 1213b994a965b69dca0bd131705d98363c0ff46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:34:21 +0200 Subject: [PATCH 02/13] Add static_cast() for the Mixxx size and index type when coming from std types --- src/engine/bufferscalers/enginebufferscalerubberband.cpp | 6 +++--- src/musicbrainz/chromaprinter.cpp | 2 +- src/sources/soundsourcemodplug.cpp | 2 +- src/sources/soundsourcemp3.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalerubberband.cpp b/src/engine/bufferscalers/enginebufferscalerubberband.cpp index 1de96510605..191b7fd04d3 100644 --- a/src/engine/bufferscalers/enginebufferscalerubberband.cpp +++ b/src/engine/bufferscalers/enginebufferscalerubberband.cpp @@ -133,8 +133,8 @@ SINT EngineBufferScaleRubberBand::retrieveAndDeinterleave( SINT frames) { SINT frames_available = m_pRubberBand->available(); SINT frames_to_read = math_min(frames_available, frames); - SINT received_frames = m_pRubberBand->retrieve( - (float* const*)m_retrieve_buffer, frames_to_read); + SINT received_frames = static_cast(m_pRubberBand->retrieve( + (float* const*)m_retrieve_buffer, frames_to_read)); SampleUtil::interleaveBuffer(pBuffer, m_retrieve_buffer[0], @@ -188,7 +188,7 @@ double EngineBufferScaleRubberBand::scaleBuffer( break; } - size_t iLenFramesRequired = m_pRubberBand->getSamplesRequired(); + SINT iLenFramesRequired = static_cast(m_pRubberBand->getSamplesRequired()); if (iLenFramesRequired == 0) { // rubberband 1.3 (packaged up through Ubuntu Quantal) has a bug // where it can report 0 samples needed forever which leads us to an diff --git a/src/musicbrainz/chromaprinter.cpp b/src/musicbrainz/chromaprinter.cpp index 370ac4bd331..f1d481e3756 100644 --- a/src/musicbrainz/chromaprinter.cpp +++ b/src/musicbrainz/chromaprinter.cpp @@ -57,7 +57,7 @@ QString calcFingerprint( SampleUtil::convertFloat32ToS16( &fingerprintSamples[0], sampleBuffer.data(), - fingerprintSamples.size()); + static_cast(fingerprintSamples.size())); qDebug() << "reading file took" << timerReadingFile.elapsed().debugMillisWithUnit(); diff --git a/src/sources/soundsourcemodplug.cpp b/src/sources/soundsourcemodplug.cpp index ac76b480d34..22b636bf574 100644 --- a/src/sources/soundsourcemodplug.cpp +++ b/src/sources/soundsourcemodplug.cpp @@ -186,7 +186,7 @@ SoundSource::OpenResult SoundSourceModPlug::tryOpen( initFrameIndexRangeOnce( IndexRange::forward( 0, - getSignalInfo().samples2frames(m_sampleBuf.size()))); + getSignalInfo().samples2frames(static_cast(m_sampleBuf.size())))); return OpenResult::Succeeded; } diff --git a/src/sources/soundsourcemp3.cpp b/src/sources/soundsourcemp3.cpp index 48b75ef4728..82f3dc05974 100644 --- a/src/sources/soundsourcemp3.cpp +++ b/src/sources/soundsourcemp3.cpp @@ -392,7 +392,7 @@ SoundSource::OpenResult SoundSourceMp3::tryOpen( // Calculate average bitrate values DEBUG_ASSERT(m_seekFrameList.size() > 0); // see above - m_avgSeekFrameCount = frameLength() / m_seekFrameList.size(); + m_avgSeekFrameCount = frameLength() / static_cast(m_seekFrameList.size()); if (cntBitrateFrames > 0) { const unsigned long avgBitrate = sumBitrateFrames / cntBitrateFrames; initBitrateOnce(avgBitrate / 1000); // bps -> kbps From a8d00ab633a13ea1a945cbd197eb2cfcaf571254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:37:05 +0200 Subject: [PATCH 03/13] remove unnecessary c-style cast --- src/engine/bufferscalers/enginebufferscalerubberband.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/bufferscalers/enginebufferscalerubberband.cpp b/src/engine/bufferscalers/enginebufferscalerubberband.cpp index 191b7fd04d3..f904983c72d 100644 --- a/src/engine/bufferscalers/enginebufferscalerubberband.cpp +++ b/src/engine/bufferscalers/enginebufferscalerubberband.cpp @@ -134,7 +134,7 @@ SINT EngineBufferScaleRubberBand::retrieveAndDeinterleave( SINT frames_available = m_pRubberBand->available(); SINT frames_to_read = math_min(frames_available, frames); SINT received_frames = static_cast(m_pRubberBand->retrieve( - (float* const*)m_retrieve_buffer, frames_to_read)); + m_retrieve_buffer, frames_to_read)); SampleUtil::interleaveBuffer(pBuffer, m_retrieve_buffer[0], @@ -149,8 +149,9 @@ void EngineBufferScaleRubberBand::deinterleaveAndProcess( SampleUtil::deinterleaveBuffer( m_retrieve_buffer[0], m_retrieve_buffer[1], pBuffer, frames); - m_pRubberBand->process((const float* const*)m_retrieve_buffer, - frames, flush); + m_pRubberBand->process(m_retrieve_buffer, + frames, + flush); } double EngineBufferScaleRubberBand::scaleBuffer( From ed1f096ba3f158748996ad2facf6a7065b590a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 24 Jul 2022 10:07:16 +0200 Subject: [PATCH 04/13] Improve loop index type --- src/controllers/controller.cpp | 8 +++++--- src/controllers/hid/hidiothread.cpp | 2 +- src/controllers/midi/portmidicontroller.cpp | 2 +- src/effects/backends/builtin/whitenoiseeffect.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/controllers/controller.cpp b/src/controllers/controller.cpp index aeb5f95d408..93dbd9dccdf 100644 --- a/src/controllers/controller.cpp +++ b/src/controllers/controller.cpp @@ -95,11 +95,13 @@ void Controller::send(const QList& data, unsigned int length) { // If you change this implementation, also change it in HidController (That // function is required due to HID devices having report IDs) + Q_UNUSED(length); // The length parameter is here for backwards compatibility for when scripts // were required to specify it. - length = data.size(); - QByteArray msg(length, 0); - for (unsigned int i = 0; i < length; ++i) { + + int size = data.size(); + QByteArray msg(size, 0); + for (int i = 0; i < size; ++i) { msg[i] = data.at(i); } sendBytes(msg); diff --git a/src/controllers/hid/hidiothread.cpp b/src/controllers/hid/hidiothread.cpp index 95fdf41bcea..6b295f64d99 100644 --- a/src/controllers/hid/hidiothread.cpp +++ b/src/controllers/hid/hidiothread.cpp @@ -213,7 +213,7 @@ bool HidIoThread::sendNextCachedOutputReport() { // i is just a counter to prevent infinite loop execution. // If the map size increases, this loop will execute one iteration more, // which only has the effect, that one additional lookup operation for unsent data will be executed. - for (unsigned char i = 0; i < m_outputReports.size(); i++) { + for (std::size_t i = 0; i < m_outputReports.size(); i++) { auto mapLock = lockMutex(&m_outputReportMapMutex); if (m_outputReportIterator == m_outputReports.end()) { m_outputReportIterator = m_outputReports.begin(); diff --git a/src/controllers/midi/portmidicontroller.cpp b/src/controllers/midi/portmidicontroller.cpp index 2de0d6af35e..3ef38101cdd 100644 --- a/src/controllers/midi/portmidicontroller.cpp +++ b/src/controllers/midi/portmidicontroller.cpp @@ -18,7 +18,7 @@ PortMidiController::PortMidiController(const PmDeviceInfo* inputDeviceInfo, : kUnknownControllerName), m_cReceiveMsg_index(0), m_bInSysex(false) { - for (unsigned int k = 0; k < MIXXX_PORTMIDI_BUFFER_LEN; ++k) { + for (int k = 0; k < MIXXX_PORTMIDI_BUFFER_LEN; ++k) { // Can be shortened to `m_midiBuffer[k] = {}` with C++11. m_midiBuffer[k].message = 0; m_midiBuffer[k].timestamp = 0; diff --git a/src/effects/backends/builtin/whitenoiseeffect.cpp b/src/effects/backends/builtin/whitenoiseeffect.cpp index c8485889b69..8e899b43ba6 100644 --- a/src/effects/backends/builtin/whitenoiseeffect.cpp +++ b/src/effects/backends/builtin/whitenoiseeffect.cpp @@ -56,7 +56,7 @@ void WhiteNoiseEffect::processChannel( std::uniform_real_distribution<> r_distributor(0.0, 1.0); - for (unsigned int i = 0; i < engineParameters.samplesPerBuffer(); i++) { + for (SINT i = 0; i < engineParameters.samplesPerBuffer(); i++) { CSAMPLE_GAIN drywet_ramped = drywet_ramping_value.getNth(i); float noise = static_cast( From 9b3cd85eac4d85c4b736a826d7cc9722734ceb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 24 Jul 2022 10:10:23 +0200 Subject: [PATCH 05/13] Use curly brace initializer (remove todo) --- src/controllers/midi/portmidicontroller.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/controllers/midi/portmidicontroller.cpp b/src/controllers/midi/portmidicontroller.cpp index 3ef38101cdd..e08783e2a2e 100644 --- a/src/controllers/midi/portmidicontroller.cpp +++ b/src/controllers/midi/portmidicontroller.cpp @@ -19,9 +19,7 @@ PortMidiController::PortMidiController(const PmDeviceInfo* inputDeviceInfo, m_cReceiveMsg_index(0), m_bInSysex(false) { for (int k = 0; k < MIXXX_PORTMIDI_BUFFER_LEN; ++k) { - // Can be shortened to `m_midiBuffer[k] = {}` with C++11. - m_midiBuffer[k].message = 0; - m_midiBuffer[k].timestamp = 0; + m_midiBuffer[k] = {0, 0}; } // Note: We prepend the input stream's index to the device's name to prevent From 9600b71924ca6cdfef84cdc514b6ef4f225c7944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 24 Jul 2022 21:00:19 +0200 Subject: [PATCH 06/13] Use QChar for the CHECK MARK sign to avoid a MSVC warning --- src/widget/weffectchainpresetbutton.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widget/weffectchainpresetbutton.cpp b/src/widget/weffectchainpresetbutton.cpp index 46e511ecfb0..d47a62aa62c 100644 --- a/src/widget/weffectchainpresetbutton.cpp +++ b/src/widget/weffectchainpresetbutton.cpp @@ -50,7 +50,8 @@ void WEffectChainPresetButton::populateMenu() { for (const auto& pChainPreset : m_pChainPresetManager->getPresetsSorted()) { QString title = pChainPreset->name(); if (title == m_pChain->presetName()) { - title = QStringLiteral("\u2713 ") + title; + title = QChar(0x2713) + // CHECK MARK + QChar(' ') + title; chainIsPreset = true; } m_pMenu->addAction(title, this, [this, pChainPreset]() { From 3bb06e8961beb2421372279c0a0dd0a51fead087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:42:37 +0200 Subject: [PATCH 07/13] libshout-idjc: silence various "possible loss of data" warnings by type casts --- lib/libshout-idjc/src/common/httpp/encoding.c | 16 ++++++++-------- lib/libshout-idjc/src/common/httpp/httpp.c | 10 +++++----- lib/libshout-idjc/src/common/net/sock.c | 6 +++--- lib/libshout-idjc/src/common/thread/thread.c | 4 ++-- lib/libshout-idjc/src/common/timing/timing.c | 6 +++--- lib/libshout-idjc/src/format_mpeg.c | 18 +++++++++--------- lib/libshout-idjc/src/format_ogg.c | 4 ++-- lib/libshout-idjc/src/proto_roaraudio.c | 8 ++++---- lib/libshout-idjc/src/queue.c | 4 ++-- lib/libshout-idjc/src/shout.c | 10 +++++----- lib/libshout-idjc/src/tls.c | 6 +++--- 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/libshout-idjc/src/common/httpp/encoding.c b/lib/libshout-idjc/src/common/httpp/encoding.c index e1c1236b501..8e6f775a4c7 100644 --- a/lib/libshout-idjc/src/common/httpp/encoding.c +++ b/lib/libshout-idjc/src/common/httpp/encoding.c @@ -94,7 +94,7 @@ ssize_t __copy_buffer(void *dst, void **src, size_t *boffset, size_t *blen, size *blen = 0; } - return todo; + return (ssize_t)todo; } /* try to flush output buffers */ @@ -326,7 +326,7 @@ ssize_t httpp_encoding_pending(httpp_encoding_t *self) return -1; if (!self->buf_write_encoded) return 0; - return self->buf_write_encoded_len - self->buf_write_encoded_offset; + return (ssize_t)(self->buf_write_encoded_len - self->buf_write_encoded_offset); } /* Attach meta data to the stream. @@ -565,11 +565,11 @@ static ssize_t __enc_chunked_read(httpp_encoding_t *self, void *buf, size_t len, if (*c == '"') { in_quote = 1; } else if (*c == ';' && offset_extentions == -1) { - offset_extentions = i; + offset_extentions = (ssize_t)i; } else if (*c == '\r') { - offset_CR = i; + offset_CR = (ssize_t)i; } else if (*c == '\n' && offset_CR == (ssize_t)(i - 1)) { - offset_LF = i; + offset_LF = (ssize_t)i; break; } } @@ -760,8 +760,8 @@ static ssize_t __enc_chunked_write(httpp_encoding_t *self, const void *buf, size extensions = __enc_chunked_write_extensions(self); /* 2 = end of header and tailing "\r\n" */ - header_length = strlen(encoded_length) + (extensions ? strlen(extensions) : 0) + 2; - total_chunk_size = header_length + len + 2; + header_length = (ssize_t)(strlen(encoded_length) + (extensions ? strlen(extensions) : 0) + 2); + total_chunk_size = header_length + (ssize_t)(len + 2); if (!buf) total_chunk_size += 2; @@ -783,5 +783,5 @@ static ssize_t __enc_chunked_write(httpp_encoding_t *self, const void *buf, size if (extensions) free(extensions); - return len; + return (ssize_t)len; } diff --git a/lib/libshout-idjc/src/common/httpp/httpp.c b/lib/libshout-idjc/src/common/httpp/httpp.c index 4c320d378f1..bb9707681a9 100644 --- a/lib/libshout-idjc/src/common/httpp/httpp.c +++ b/lib/libshout-idjc/src/common/httpp/httpp.c @@ -117,7 +117,7 @@ static void parse_headers(http_parser_t *parser, char **line, int lines) whitespace = 0; name = line[l]; value = NULL; - slen = strlen(line[l]); + slen = (int)strlen(line[l]); for (i = 0; i < slen; i++) { if (line[l][i] == ':') { whitespace = 1; @@ -165,7 +165,7 @@ int httpp_parse_response(http_parser_t *parser, const char *http_data, unsigned /* In this case, the first line contains: * VERSION RESPONSE_CODE MESSAGE, such as HTTP/1.0 200 OK */ - slen = strlen(line[0]); + slen = (int)strlen(line[0]); version = line[0]; for(i=0; i < slen; i++) { if(line[0][i] == ' ') { @@ -218,7 +218,7 @@ static int hex(char c) static char *url_escape(const char *src) { - int len = strlen(src); + int len = (int)strlen(src); unsigned char *decoded; int i; char *dst; @@ -277,7 +277,7 @@ static void parse_query(http_parser_t *parser, char *query) if(!query || !*query) return; - len = strlen(query); + len = (int)strlen(query); while(icond_mutex); pthread_cond_timedwait(&cond->sys_cond, &cond->cond_mutex, &time); @@ -606,7 +606,7 @@ void thread_exit_c(long val, int line, char *file) _mutex_unlock(&_threadtree_mutex); } - pthread_exit ((void*)val); + pthread_exit ((void*)(size_t)val); } /* sleep for a number of microseconds */ diff --git a/lib/libshout-idjc/src/common/timing/timing.c b/lib/libshout-idjc/src/common/timing/timing.c index 9be67d565a6..846fc4c9a53 100644 --- a/lib/libshout-idjc/src/common/timing/timing.c +++ b/lib/libshout-idjc/src/common/timing/timing.c @@ -88,8 +88,8 @@ void timing_sleep(uint64_t sleeptime) { struct timeval sleeper; - sleeper.tv_sec = sleeptime / 1000; - sleeper.tv_usec = (sleeptime % 1000) * 1000; + sleeper.tv_sec = (long)(sleeptime / 1000); + sleeper.tv_usec = (long)((sleeptime % 1000) * 1000); /* NOTE: * This should be 0 for the first argument. The linux manpage @@ -97,7 +97,7 @@ void timing_sleep(uint64_t sleeptime) * value. If you think differerntly, please provide references. */ #ifdef WIN32 - Sleep(sleeptime); + Sleep((DWORD)sleeptime); #else select(1, NULL, NULL, NULL, &sleeper); #endif diff --git a/lib/libshout-idjc/src/format_mpeg.c b/lib/libshout-idjc/src/format_mpeg.c index adf84d9b1f2..c727f974949 100644 --- a/lib/libshout-idjc/src/format_mpeg.c +++ b/lib/libshout-idjc/src/format_mpeg.c @@ -127,7 +127,7 @@ static int open_mpeg(shout_t *self, size_t header_size, int (*reader)(const uint self->send = send_mpeg; self->close = close_mpeg; - mpeg_data->header_size = header_size; + mpeg_data->header_size = (int)header_size; mpeg_data->header_read = reader; return SHOUTERR_SUCCESS; @@ -146,7 +146,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len) pos = 0; start = 0; error = 0; - end = len - 1; + end = (int)len - 1; /* finish the previous frame */ if (mpeg_data->frame_left > 0) { @@ -157,8 +157,8 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len) pos += mpeg_data->frame_left; mpeg_data->frame_left = 0; } else { - mpeg_data->frame_left -= len; - pos = len; + mpeg_data->frame_left -= (unsigned int)len; + pos = (unsigned long)len; } } @@ -174,7 +174,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len) buff = bridge_buff; len += mpeg_data->header_bridges; - end = len - 1; + end = (int)len - 1; mpeg_data->header_bridges = 0; } @@ -187,7 +187,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len) if (mpeg_data->header_read(&buff[pos], &mh)) { if (error) { start = pos; - end = len - 1; + end = (int)len - 1; error = 0; } @@ -200,8 +200,8 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len) mpeg_data->frames++; pos += mh.framesize; } else { - mpeg_data->frame_left = mh.framesize - (len - pos); - pos = len; + mpeg_data->frame_left = (unsigned int)(mh.framesize - (len - pos)); + pos = (unsigned long)len; } } else { /* there was an error @@ -324,7 +324,7 @@ static int adts_header(const uint8_t *window, header_digest_t *mh) return 0; /* make sure frame length is sane */ - if (mh->framesize < (h.protection_absent ? MIN_ADTS_HEADER_SIZE : MAX_ADTS_HEADER_SIZE)) + if (mh->framesize < (unsigned int)(h.protection_absent ? MIN_ADTS_HEADER_SIZE : MAX_ADTS_HEADER_SIZE)) return 0; return 1; diff --git a/lib/libshout-idjc/src/format_ogg.c b/lib/libshout-idjc/src/format_ogg.c index 2857429d561..afca012348d 100644 --- a/lib/libshout-idjc/src/format_ogg.c +++ b/lib/libshout-idjc/src/format_ogg.c @@ -90,9 +90,9 @@ static int send_ogg(shout_t *self, const unsigned char *data, size_t len) char *buffer; ogg_page page; - buffer = ogg_sync_buffer(&ogg_data->oy, len); + buffer = ogg_sync_buffer(&ogg_data->oy, (long)len); memcpy(buffer, data, len); - ogg_sync_wrote(&ogg_data->oy, len); + ogg_sync_wrote(&ogg_data->oy, (long)len); while (ogg_sync_pageout(&ogg_data->oy, &page) == 1) { if (ogg_page_bos(&page)) { diff --git a/lib/libshout-idjc/src/proto_roaraudio.c b/lib/libshout-idjc/src/proto_roaraudio.c index 55a3ec757cd..ec161bc6e17 100644 --- a/lib/libshout-idjc/src/proto_roaraudio.c +++ b/lib/libshout-idjc/src/proto_roaraudio.c @@ -131,10 +131,10 @@ static int shout_create_roaraudio_request_ident(shout_t *self) /* version number (1). */ data[0] = 1; /* PID */ - data[1] = (pid & 0xFF000000UL) >> 24; - data[2] = (pid & 0x00FF0000UL) >> 16; - data[3] = (pid & 0x0000FF00UL) >> 8; - data[4] = (pid & 0x000000FFUL) >> 0; + data[1] = (uint8_t)((pid & 0xFF000000UL) >> 24); + data[2] = (uint8_t)((pid & 0x00FF0000UL) >> 16); + data[3] = (uint8_t)((pid & 0x0000FF00UL) >> 8); + data[4] = (uint8_t)((pid & 0x000000FFUL) >> 0); /* agent name */ memcpy(data + 5, agent, datalen - 5); diff --git a/lib/libshout-idjc/src/queue.c b/lib/libshout-idjc/src/queue.c index a5274a05bb1..a2921f945d8 100644 --- a/lib/libshout-idjc/src/queue.c +++ b/lib/libshout-idjc/src/queue.c @@ -63,7 +63,7 @@ int shout_queue_data(shout_queue_t *queue, const unsigned char *data, size_t len plen = len > SHOUT_BUFSIZE - buf->len ? SHOUT_BUFSIZE - buf->len : len; memcpy(buf->data + buf->len, data, plen); - buf->len += plen; + buf->len += (unsigned int)(plen); data += plen; len -= plen; queue->len += plen; @@ -143,5 +143,5 @@ ssize_t shout_queue_collect(shout_buf_t *queue, char **buf) pos += node->len; } - return len; + return (ssize_t)len; } diff --git a/lib/libshout-idjc/src/shout.c b/lib/libshout-idjc/src/shout.c index cd73dbec654..2e8602bdcd7 100644 --- a/lib/libshout-idjc/src/shout.c +++ b/lib/libshout-idjc/src/shout.c @@ -257,7 +257,7 @@ ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len) if (self->error != SHOUTERR_SUCCESS) return self->error; } - return len; + return (ssize_t)len; } self->error = shout_queue_data(&self->wqueue, data, len); @@ -266,7 +266,7 @@ ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len) ret = send_queue(self); if (ret == SHOUTERR_SUCCESS || (len && ret == SHOUTERR_BUSY)) - return len; + return (ssize_t)len; return ret; } @@ -305,7 +305,7 @@ int shout_delay(shout_t *self) if (self->senttime == 0) return 0; - return self->senttime / 1000 - (timing_get_time() - self->starttime); + return (int)(self->senttime / 1000 - (timing_get_time() - self->starttime)); } shout_metadata_t *shout_metadata_new(void) @@ -1432,12 +1432,12 @@ static int try_write(shout_t *self, const void *data_p, size_t len) if (ret < 0) { if (shout_conn_recoverable(self)) { self->error = SHOUTERR_BUSY; - return pos; + return (int)pos; } self->error = SHOUTERR_SOCKET; return ret; } - return pos; + return (int)pos; } ssize_t shout_conn_read(shout_t *self, void *buf, size_t len) diff --git a/lib/libshout-idjc/src/tls.c b/lib/libshout-idjc/src/tls.c index 034238aafdd..485e604d7d7 100644 --- a/lib/libshout-idjc/src/tls.c +++ b/lib/libshout-idjc/src/tls.c @@ -102,7 +102,7 @@ static inline int tls_setup(shout_tls_t *tls) if (!tls->ssl) goto error; - if (!SSL_set_fd(tls->ssl, tls->socket)) + if (!SSL_set_fd(tls->ssl, (int)tls->socket)) goto error; SSL_set_tlsext_host_name(tls->ssl, tls->host); @@ -234,12 +234,12 @@ int shout_tls_close(shout_tls_t *tls) ssize_t shout_tls_read(shout_tls_t *tls, void *buf, size_t len) { - return tls->ssl_ret = SSL_read(tls->ssl, buf, len); + return tls->ssl_ret = SSL_read(tls->ssl, buf, (int)len); } ssize_t shout_tls_write(shout_tls_t *tls, const void *buf, size_t len) { - return tls->ssl_ret = SSL_write(tls->ssl, buf, len); + return tls->ssl_ret = SSL_write(tls->ssl, buf, (int)len); } int shout_tls_recoverable(shout_tls_t *tls) From 301107b6d0b04b7892387a7cb85ddfa58ef89087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:43:15 +0200 Subject: [PATCH 08/13] libshout-idjc: use size_t type to silence warning --- lib/libshout-idjc/src/proto_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libshout-idjc/src/proto_http.c b/lib/libshout-idjc/src/proto_http.c index 1b8dea38dbf..ac0e951999a 100644 --- a/lib/libshout-idjc/src/proto_http.c +++ b/lib/libshout-idjc/src/proto_http.c @@ -36,7 +36,7 @@ char *shout_http_basic_authorization(shout_t *self) { char *out, *in; - int len; + size_t len; if (!self || !self->user || !self->password) return NULL; From 355ff6d6640ed10a67c5e839e2aab58712f11988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:43:46 +0200 Subject: [PATCH 09/13] libshout-idjc: add missing include directive --- lib/libshout-idjc/src/proto_roaraudio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libshout-idjc/src/proto_roaraudio.c b/lib/libshout-idjc/src/proto_roaraudio.c index ec161bc6e17..ecdccb03c53 100644 --- a/lib/libshout-idjc/src/proto_roaraudio.c +++ b/lib/libshout-idjc/src/proto_roaraudio.c @@ -32,6 +32,10 @@ # include #endif +#ifdef _WIN32 +#include +#endif + #include #include #include From 70deb49948bc7d4a88f0b97415dab2d7d5754f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:44:17 +0200 Subject: [PATCH 10/13] libshout-idjc: print pointer via %p --- lib/libshout-idjc/src/common/avl/avl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libshout-idjc/src/common/avl/avl.c b/lib/libshout-idjc/src/common/avl/avl.c index 5653440e014..5a59063be29 100644 --- a/lib/libshout-idjc/src/common/avl/avl.c +++ b/lib/libshout-idjc/src/common/avl/avl.c @@ -1037,7 +1037,7 @@ avl_verify_rank (avl_node * node) num_right = avl_verify_rank (node->right); } if (AVL_GET_RANK (node) != num_left + 1) { - fprintf (stderr, "invalid rank at node %ld\n", (long) node->key); + fprintf (stderr, "invalid rank at node %p\n", node->key); exit (1); } return (num_left + num_right + 1); From 78e70821fe31cc5777f2aaa53ef561604290f70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:45:12 +0200 Subject: [PATCH 11/13] libshout-idjc: define sock_t as SOCKET on windows to avoid data loss warning --- lib/libshout-idjc/src/common/net/sock.c | 2 +- lib/libshout-idjc/src/common/net/sock.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libshout-idjc/src/common/net/sock.c b/lib/libshout-idjc/src/common/net/sock.c index 17f1a6063bf..70053a641b5 100644 --- a/lib/libshout-idjc/src/common/net/sock.c +++ b/lib/libshout-idjc/src/common/net/sock.c @@ -569,7 +569,7 @@ int sock_connected (sock_t sock, int timeout) FD_ZERO(&wfds); FD_SET(sock, &wfds); - switch (select(sock + 1, NULL, &wfds, NULL, timeval)) + switch (select((int)sock + 1, NULL, &wfds, NULL, timeval)) { case 0: return SOCK_TIMEOUT; diff --git a/lib/libshout-idjc/src/common/net/sock.h b/lib/libshout-idjc/src/common/net/sock.h index 7cfbafb12be..14e0f907c3f 100644 --- a/lib/libshout-idjc/src/common/net/sock.h +++ b/lib/libshout-idjc/src/common/net/sock.h @@ -62,12 +62,16 @@ struct iovec #endif #ifndef sock_t +#ifdef _WIN32 +#define sock_t SOCKET +#else #define sock_t int #endif +#endif /* The following values are based on unix avoiding errno value clashes */ #define SOCK_SUCCESS 0 -#define SOCK_ERROR (sock_t)-1 +#define SOCK_ERROR -1 #define SOCK_TIMEOUT -2 /* sock connect macro */ From c038f8935a700727a9e63b30d2ad02e09e4e03fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 20 Jul 2022 15:45:56 +0200 Subject: [PATCH 12/13] libshout-idjc: remove redundant definition to avoid a redefinition warning --- lib/libshout-idjc/src/common/thread/thread.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/libshout-idjc/src/common/thread/thread.c b/lib/libshout-idjc/src/common/thread/thread.c index beef581ba4d..2e1f2e31aff 100644 --- a/lib/libshout-idjc/src/common/thread/thread.c +++ b/lib/libshout-idjc/src/common/thread/thread.c @@ -52,10 +52,6 @@ #include #endif -#ifdef _WIN32 -#define __FUNCTION__ __FILE__ -#endif - #ifdef THREAD_DEBUG #define CATMODULE "thread" #define LOG_ERROR(y) log_write(_logid, 1, CATMODULE "/", __FUNCTION__, y) From d80ebf2a5db55236d6895e5e8b6d5629cd027027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 25 Jul 2022 14:52:52 +0200 Subject: [PATCH 13/13] Avoid zero initialization and use std::copy --- src/controllers/controller.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/controllers/controller.cpp b/src/controllers/controller.cpp index 93dbd9dccdf..db07cea1aab 100644 --- a/src/controllers/controller.cpp +++ b/src/controllers/controller.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "controllers/defs_controllers.h" #include "moc_controller.cpp" @@ -99,11 +100,9 @@ void Controller::send(const QList& data, unsigned int length) { // The length parameter is here for backwards compatibility for when scripts // were required to specify it. - int size = data.size(); - QByteArray msg(size, 0); - for (int i = 0; i < size; ++i) { - msg[i] = data.at(i); - } + QByteArray msg; + msg.resize(data.size()); + std::copy(data.cbegin(), data.cend(), msg.begin()); sendBytes(msg); }