From ca7afe11bfdd286e4f65a3ed75e26e5a3371a0b8 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Wed, 16 Jan 2019 11:17:54 +0100 Subject: [PATCH] compiler fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DStarRepeater/DStarRepeaterApp.cpp suggest explicit braces to avoid ambiguous ‘else’ * Common/AudioCallback.h * Common/SoundCardController.cpp * Common/SoundCardController.h * Common/SoundCardReaderWriter.cpp comparison between signed and unsigned integer expressions backport from MMDVM-UDRC "Fix signed integer issues with compiler" by mcdermj fix issue #4 --- Common/AudioCallback.h | 2 +- Common/SoundCardController.cpp | 2 +- Common/SoundCardController.h | 2 +- Common/SoundCardReaderWriter.cpp | 12 ++++++------ DStarRepeater/DStarRepeaterApp.cpp | 6 ++++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Common/AudioCallback.h b/Common/AudioCallback.h index fb37a1d..3259369 100644 --- a/Common/AudioCallback.h +++ b/Common/AudioCallback.h @@ -19,7 +19,7 @@ class IAudioCallback { public: virtual void readCallback(const wxFloat32* input, unsigned int nSamples, int id) = 0; - virtual void writeCallback(wxFloat32* output, unsigned int& nSamples, int id) = 0; + virtual void writeCallback(wxFloat32* output, int& nSamples, int id) = 0; private: }; diff --git a/Common/SoundCardController.cpp b/Common/SoundCardController.cpp index 5e83c8a..c69f33d 100644 --- a/Common/SoundCardController.cpp +++ b/Common/SoundCardController.cpp @@ -591,7 +591,7 @@ void CSoundCardController::readCallback(const wxFloat32* input, unsigned int n, #endif } -void CSoundCardController::writeCallback(wxFloat32* output, unsigned int& n, int id) +void CSoundCardController::writeCallback(wxFloat32* output, int& n, int id) { if (n == 0U) return; diff --git a/Common/SoundCardController.h b/Common/SoundCardController.h index 087a939..44da8a5 100644 --- a/Common/SoundCardController.h +++ b/Common/SoundCardController.h @@ -52,7 +52,7 @@ public: virtual bool writeData(const unsigned char* data, unsigned int length, bool end); virtual void readCallback(const wxFloat32* input, unsigned int n, int id); - virtual void writeCallback(wxFloat32* output, unsigned int& n, int id); + virtual void writeCallback(wxFloat32* output, int& n, int id); private: CSoundCardReaderWriter m_sound; diff --git a/Common/SoundCardReaderWriter.cpp b/Common/SoundCardReaderWriter.cpp index 62a15f4..846e640 100644 --- a/Common/SoundCardReaderWriter.cpp +++ b/Common/SoundCardReaderWriter.cpp @@ -730,25 +730,25 @@ void* CSoundCardWriter::Entry() wxLogMessage(wxT("Starting ALSA writer thread")); while (!m_killed) { - unsigned int nSamples = 2U * m_blockSize; + int nSamples = 2U * m_blockSize; m_callback->writeCallback(m_buffer, nSamples, m_id); if (nSamples == 0U) { Sleep(5UL); } else { if (m_channels == 1U) { - for (unsigned int n = 0U; n < nSamples; n++) + for (int n = 0U; n < nSamples; n++) m_samples[n] = short(m_buffer[n] * 32767.0F); } else { - unsigned int i = 0U; - for (unsigned int n = 0U; n < nSamples; n++) { + int i = 0U; + for (int n = 0U; n < nSamples; n++) { short sample = short(m_buffer[n] * 32767.0F); m_samples[i++] = sample; m_samples[i++] = sample; // Same value to both channels } } - unsigned int offset = 0U; + int offset = 0U; snd_pcm_sframes_t ret; while ((ret = ::snd_pcm_writei(m_handle, m_samples + offset, nSamples - offset)) != (nSamples - offset)) { if (ret < 0) { @@ -759,7 +759,7 @@ void* CSoundCardWriter::Entry() ::snd_pcm_recover(m_handle, ret, 1); } else { - offset += (unsigned int)ret; + offset += ret; } } } diff --git a/DStarRepeater/DStarRepeaterApp.cpp b/DStarRepeater/DStarRepeaterApp.cpp index a1779aa..07e5d72 100644 --- a/DStarRepeater/DStarRepeaterApp.cpp +++ b/DStarRepeater/DStarRepeaterApp.cpp @@ -503,13 +503,15 @@ void CDStarRepeaterApp::createThread() wxLogInfo("Split, local: %s:%u, timeout: %u ms", localAddress.c_str(), localPort, timeout); for (unsigned int i = 0U; i < transmitterNames.GetCount(); i++) { wxString name = transmitterNames.Item(i); - if (!name.IsEmpty()) + if (!name.IsEmpty()) { wxLogInfo("\tTX %u name: %s", i + 1U, name.c_str()); + } } for (unsigned int i = 0U; i < receiverNames.GetCount(); i++) { wxString name = receiverNames.Item(i); - if (!name.IsEmpty()) + if (!name.IsEmpty()) { wxLogInfo("\tRX %u name: %s", i + 1U, name.c_str()); + } } modem = new CSplitController(localAddress, localPort, transmitterNames, receiverNames, timeout); } else if (modemType.IsSameAs("Icom Access Point/Terminal Mode")) {