diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-04-30 14:52:52 +0400 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-04-30 14:52:52 +0400 |
commit | 936ef86d86a7c377e9f5cf5fd0326431c59f14c2 (patch) | |
tree | d9882e057e572b4938875c7412297d5e68b6966c | |
parent | 53d2343c75bb6615cc01eb4c9163d8f34caf67f8 (diff) |
Remove a lot of compiler warnings
m--------- | celt | 0 | ||||
-rw-r--r-- | src/Connection.cpp | 8 | ||||
-rw-r--r-- | src/Message.h | 2 | ||||
-rw-r--r-- | src/mumble/ALSAAudio.cpp | 20 | ||||
-rw-r--r-- | src/mumble/AudioConfigDialog.cpp | 24 | ||||
-rw-r--r-- | src/mumble/AudioInput.cpp | 16 | ||||
-rw-r--r-- | src/mumble/AudioOutput.cpp | 12 | ||||
-rw-r--r-- | src/mumble/AudioStats.cpp | 20 | ||||
-rw-r--r-- | src/mumble/AudioWizard.cpp | 2 | ||||
-rw-r--r-- | src/mumble/BanEditor.cpp | 18 | ||||
-rw-r--r-- | src/mumble/Cert.cpp | 14 | ||||
-rw-r--r-- | src/mumble/Log.cpp | 6 | ||||
-rw-r--r-- | src/mumble/MainWindow.cpp | 3 | ||||
-rw-r--r-- | src/mumble/Messages.cpp | 2 | ||||
-rw-r--r-- | src/mumble/OSS.cpp | 10 | ||||
-rw-r--r-- | src/mumble/Overlay.cpp | 6 | ||||
-rw-r--r-- | src/mumble/Overlay_unix.cpp | 2 | ||||
-rw-r--r-- | src/mumble/ServerHandler.cpp | 30 | ||||
-rw-r--r-- | src/mumble/mumble_pch.hpp | 2 | ||||
-rw-r--r-- | src/murmur/Cert.cpp | 10 | ||||
-rw-r--r-- | src/murmur/Messages.cpp | 19 | ||||
-rw-r--r-- | src/murmur/MurmurIce.cpp | 4 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 10 | ||||
-rw-r--r-- | src/murmur/ServerDB.cpp | 8 | ||||
-rw-r--r-- | src/murmur/UnixMurmur.cpp | 2 |
25 files changed, 129 insertions, 121 deletions
diff --git a/celt b/celt -Subproject eafbdd55312151ae8ad142e2a0be099787765b2 +Subproject 433820954fb2e38d951dffaa77dc2ca3e3d288c diff --git a/src/Connection.cpp b/src/Connection.cpp index 9ba2ce31e..f2bcf41f2 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -150,10 +150,10 @@ void Connection::messageToNetwork(const ::google::protobuf::Message &msg, unsign return; cache.resize(len + 4); unsigned char *uc = reinterpret_cast<unsigned char *>(cache.data()); - uc[0] = msgType; - uc[1] = (len >> 16) & 0xFF; - uc[2] = (len >> 8) & 0xFF; - uc[3] = len & 0xFF; + uc[0] = static_cast<unsigned char>(msgType); + uc[1] = static_cast<unsigned char>((len >> 16) & 0xFF); + uc[2] = static_cast<unsigned char>((len >> 8) & 0xFF); + uc[3] = static_cast<unsigned char>(len & 0xFF); msg.SerializeToArray(uc + 4, len); } diff --git a/src/Message.h b/src/Message.h index ac53df5bf..623a6b394 100644 --- a/src/Message.h +++ b/src/Message.h @@ -66,7 +66,7 @@ class MessageHandler { }; inline QString u8(const ::std::string &str) { - return QString::fromUtf8(str.data(), str.length()); + return QString::fromUtf8(str.data(), static_cast<int>(str.length())); } inline QString u8(const ::std::wstring &str) { diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp index 4bb514360..7c60faea8 100644 --- a/src/mumble/ALSAAudio.cpp +++ b/src/mumble/ALSAAudio.cpp @@ -306,7 +306,7 @@ ALSAAudioInput::~ALSAAudioInput() { void ALSAAudioInput::run() { QMutexLocker qml(&qmALSA); - int readblapp; + snd_pcm_sframes_t readblapp; QByteArray device_name = g.s.qsALSAInput.toLatin1(); snd_pcm_hw_params_t *hw_params = NULL; @@ -376,18 +376,18 @@ void ALSAAudioInput::run() { snd_pcm_status_dump(status, log); snd_pcm_status_free(status); #endif - readblapp = snd_pcm_readi(capture_handle, inbuff, wantPeriod); + readblapp = snd_pcm_readi(capture_handle, inbuff, static_cast<int>(wantPeriod)); if (readblapp == -ESTRPIPE) { // suspend event - what to do? - qWarning("ALSAAudioInput: %s", snd_strerror(readblapp)); + qWarning("ALSAAudioInput: %s", snd_strerror(static_cast<int>(readblapp))); } else if (readblapp == -EPIPE) { err = snd_pcm_prepare(capture_handle); - qWarning("ALSAAudioInput: %s: %s", snd_strerror(readblapp), snd_strerror(err)); + qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast<int>(readblapp)), snd_strerror(err)); } else if (readblapp < 0) { err = snd_pcm_prepare(capture_handle); - qWarning("ALSAAudioInput: %s: %s", snd_strerror(readblapp), snd_strerror(err)); + qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast<int>(readblapp)), snd_strerror(err)); } else if (wantPeriod == static_cast<unsigned int>(readblapp)) { - addMic(inbuff, readblapp); + addMic(inbuff, static_cast<int>(readblapp)); } } @@ -467,7 +467,7 @@ void ALSAAudioOutput::run() { ALSA_ERRBAIL(snd_pcm_prepare(pcm_handle)); - const unsigned int buffsize = period_size * iChannels; + const unsigned int buffsize = static_cast<unsigned int>(period_size * iChannels); float zerobuff[buffsize]; float outbuff[buffsize]; @@ -523,14 +523,14 @@ void ALSAAudioOutput::run() { snd_pcm_prepare(pcm_handle); } else if (revents & POLLOUT) { while (snd_pcm_avail_update(pcm_handle) >= static_cast<int>(period_size)) { - stillRun = mix(outbuff, period_size); - int w = 0; + stillRun = mix(outbuff, static_cast<int>(period_size)); + snd_pcm_sframes_t w = 0; if (stillRun) w=snd_pcm_writei(pcm_handle, outbuff, period_size); else break; if (w == -EPIPE) { - qWarning("ALSAAudioOutput: %s", snd_strerror(w)); + qWarning("ALSAAudioOutput: %s", snd_strerror(static_cast<int>(w))); snd_pcm_prepare(pcm_handle); for (unsigned int i=0;i< buffer_size / period_size;i++) snd_pcm_writei(pcm_handle, zerobuff, period_size); diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp index 4a04e0d03..9c005c7c9 100644 --- a/src/mumble/AudioConfigDialog.cpp +++ b/src/mumble/AudioConfigDialog.cpp @@ -106,10 +106,10 @@ void AudioInputDialog::load(const Settings &r) { loadComboBox(qcbTransmit, r.atTransmit); loadSlider(qsTransmitHold, r.iVoiceHold); - loadSlider(qsTransmitMin, lroundf(r.fVADmin * 32767.0f)); - loadSlider(qsTransmitMax, lroundf(r.fVADmax * 32767.0f)); + loadSlider(qsTransmitMin, iroundf(r.fVADmin * 32767.0f)); + loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f)); loadSlider(qsFrames, r.iFramesPerPacket); - loadSlider(qsDoublePush, lround(static_cast<double>(r.uiDoublePush) / 1000.f)); + loadSlider(qsDoublePush, iroundf(static_cast<float>(r.uiDoublePush) / 1000.f)); if (r.vsVAD == Settings::Amplitude) qrbAmplitude->setChecked(true); @@ -302,9 +302,9 @@ void AudioInputDialog::on_Tick_timeout() { abSpeech->iAbove = qsTransmitMax->value(); if (qrbAmplitude->isChecked()) { - abSpeech->iValue = lroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); + abSpeech->iValue = iroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); } else { - abSpeech->iValue = lroundf(ai->fSpeechProb * 32767.0f); + abSpeech->iValue = iroundf(ai->fSpeechProb * 32767.0f); } abSpeech->update(); } @@ -351,16 +351,16 @@ void AudioOutputDialog::load(const Settings &r) { loadComboBox(qcbSystem, i); loadSlider(qsDelay, r.iOutputDelay); - loadSlider(qsVolume, static_cast<int>(lroundf(r.fVolume * 100.0f))); - loadSlider(qsOtherVolume, static_cast<int>(lroundf(r.fOtherVolume * 100.0f))); + loadSlider(qsVolume, iroundf(r.fVolume * 100.0f)); + loadSlider(qsOtherVolume, iroundf(r.fOtherVolume * 100.0f)); loadSlider(qsJitter, r.iJitterBufferSize); loadComboBox(qcbLoopback, r.lmLoopMode); loadSlider(qsPacketDelay, static_cast<int>(r.dMaxPacketDelay)); - loadSlider(qsPacketLoss, static_cast<int>(lroundf(r.dPacketLoss * 100.0f))); - loadSlider(qsMinDistance, lroundf(r.fAudioMinDistance * 10.0f)); - loadSlider(qsMaxDistance, lroundf(r.fAudioMaxDistance * 10.0f)); - loadSlider(qsMaxDistVolume, lroundf(r.fAudioMaxDistVolume * 100.0f)); - loadSlider(qsBloom, lround(r.fAudioBloom * 100.0f)); + loadSlider(qsPacketLoss, iroundf(r.dPacketLoss * 100.0f)); + loadSlider(qsMinDistance, iroundf(r.fAudioMinDistance * 10.0f)); + loadSlider(qsMaxDistance, iroundf(r.fAudioMaxDistance * 10.0f)); + loadSlider(qsMaxDistVolume, iroundf(r.fAudioMaxDistVolume * 100.0f)); + loadSlider(qsBloom, iroundf(r.fAudioBloom * 100.0f)); loadCheckBox(qcbHeadphones, r.bPositionalHeadphone); loadCheckBox(qcbPositional, r.bPositionalAudio); } diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index d886e01c2..4e1e42a93 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -316,8 +316,8 @@ void AudioInput::initializeMixer() { imfMic = chooseMixer(iMicChannels, eMicFormat); imfEcho = chooseMixer(iEchoChannels, eEchoFormat); - iMicSampleSize = iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short)); - iEchoSampleSize = iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short)); + iMicSampleSize = static_cast<int>(iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short))); + iEchoSampleSize = static_cast<int>(iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short))); bResetProcessor = true; @@ -356,7 +356,7 @@ void AudioInput::addMic(const void *data, unsigned int nsamp) { if (iEchoChannels > 0) { JitterBufferPacket jbp; jbp.data = reinterpret_cast<char *>(psSpeaker); - jbp.len = iFrameSize * sizeof(short) * iEchoFrameSize; + jbp.len = static_cast<int>(iEchoFrameSize * sizeof(short)); jbp.timestamp = 0; jbp.span = 0; jbp.sequence = 0; @@ -382,7 +382,7 @@ void AudioInput::addEcho(const void *data, unsigned int nsamp) { pfEchoInput[i] = reinterpret_cast<const float *>(data)[i]; else for (unsigned int i=0;i<iEchoMCLength;++i) - pfEchoInput[i] = reinterpret_cast<const short *>(data)[i] * (1.0f / 32768.f); + pfEchoInput[i] = static_cast<float>(reinterpret_cast<const short *>(data)[i]) * (1.0f / 32768.f); } else { imfEcho(pfEchoInput + iEchoFilled, data, left, iEchoChannels); } @@ -409,12 +409,12 @@ void AudioInput::addEcho(const void *data, unsigned int nsamp) { speex_resampler_process_interleaved_float(srsEcho, pfEchoInput, &inlen, pfOutput, &outlen); } const float mul = 32768.f; - for (int j=0;j<iEchoFrameSize;++j) + for (unsigned int j=0;j<iEchoFrameSize;++j) outbuff[j] = static_cast<short>(ptr[j] * mul); JitterBufferPacket jbp; jbp.data = reinterpret_cast<char *>(outbuff); - jbp.len = iEchoFrameSize * sizeof(short); + jbp.len = static_cast<int>(iEchoFrameSize * sizeof(short)); jbp.timestamp = ++iJitterSeq * 10; jbp.span = 10; jbp.sequence = static_cast<unsigned short>(iJitterSeq); @@ -482,7 +482,7 @@ void AudioInput::setMaxBandwidth(int bytespersec) { } while (audiorate > bytespersec); g.iAudioBandwidth = audiorate; - g.iAudioQuality = lroundf(f); + g.iAudioQuality = iroundf(f); } void AudioInput::encodeAudioFrame() { @@ -569,7 +569,7 @@ void AudioInput::encodeAudioFrame() { speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_TARGET, &iArg); float v = 30000.0f / static_cast<float>(g.s.iMinLoudness); - iArg = lroundf(floorf(20.0f * log10f(v))); + iArg = iroundf(floorf(20.0f * log10f(v))); speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg); iArg = g.s.iNoiseSuppress; diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index 21f0457e0..7973f8b53 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -126,7 +126,7 @@ AudioOutputSample::AudioOutputSample(const QString &filename, const QList<QByteA iFrameSize = 320; - iOutputSize = lroundf(ceilf(static_cast<float>(iFrameSize * freq) / static_cast<float>(16000))); + iOutputSize = iroundf(ceilf(static_cast<float>(iFrameSize * freq) / static_cast<float>(16000))); iBufferOffset = iBufferFilled = iLastConsume = 0; @@ -186,7 +186,7 @@ QList<QByteArray> AudioOutputSample::getPacketsFromFile(const QString &filename) ogg_stream_pagein(&stream, &page); while (! eos && ogg_stream_packetout(&stream, &packet) == 1) { if (packet.bytes >= 5 && memcmp(packet.packet, "Speex", 5)==0) { - speex_serialno = stream.serialno; + speex_serialno = static_cast<int>(stream.serialno); } if (speex_serialno == -1 || stream.serialno != speex_serialno) break; @@ -194,7 +194,7 @@ QList<QByteArray> AudioOutputSample::getPacketsFromFile(const QString &filename) ++packetno; if (packetno == 0) { - SpeexHeader *header = speex_packet_to_header(reinterpret_cast<char *>(packet.packet), packet.bytes); + SpeexHeader *header = speex_packet_to_header(reinterpret_cast<char *>(packet.packet), static_cast<int>(packet.bytes)); if (header && header->speex_version_id == 1 && header->rate == 16000 && header->nb_channels == 1) { header_ok = true; @@ -207,7 +207,7 @@ QList<QByteArray> AudioOutputSample::getPacketsFromFile(const QString &filename) } else { if (packet.e_o_s) eos = true; - packets << QByteArray(reinterpret_cast<const char *>(packet.packet), packet.bytes); + packets << QByteArray(reinterpret_cast<const char *>(packet.packet), static_cast<int>(packet.bytes)); } } } @@ -288,7 +288,7 @@ AudioOutputSpeech::AudioOutputSpeech(ClientPlayer *player, unsigned int freq) : else srs = NULL; - iOutputSize = lroundf(ceilf(static_cast<float>(iFrameSize * freq) / static_cast<float>(SAMPLE_RATE))); + iOutputSize = iroundf(ceilf(static_cast<float>(iFrameSize * freq) / static_cast<float>(SAMPLE_RATE))); iBufferOffset = iBufferFilled = iLastConsume = 0; bLastAlive = true; @@ -679,7 +679,7 @@ void AudioOutput::initializeMixer(const unsigned int *chanmasks, bool forceheadp } } } - iSampleSize = iChannels * ((eSampleFormat == SampleFloat) ? sizeof(float) : sizeof(short)); + iSampleSize = static_cast<int>(iChannels * ((eSampleFormat == SampleFloat) ? sizeof(float) : sizeof(short))); qWarning("AudioOutput: Initialized %d channel %d hz mixer", iChannels, iMixerFreq); } diff --git a/src/mumble/AudioStats.cpp b/src/mumble/AudioStats.cpp index 332c5de39..5e6a98e49 100644 --- a/src/mumble/AudioStats.cpp +++ b/src/mumble/AudioStats.cpp @@ -69,12 +69,12 @@ void AudioBar::paintEvent(QPaintEvent *) { float scale = static_cast<float>(width()) / static_cast<float>(iMax - iMin); int h = height(); - int val = lroundf(iValue * scale); - int below = lroundf(iBelow * scale); - int above = lroundf(iAbove * scale); - int max = lroundf(iMax * scale); - int min = lroundf(iMin * scale); - int peak = lroundf(iPeak * scale); + int val = iroundf(static_cast<float>(iValue) * scale); + int below = iroundf(static_cast<float>(iBelow) * scale); + int above = iroundf(static_cast<float>(iAbove) * scale); + int max = iroundf(static_cast<float>(iMax) * scale); + int min = iroundf(static_cast<float>(iMin) * scale); + int peak = iroundf(static_cast<float>(iPeak) * scale); if (val <= below) { p.fillRect(0, 0, val, h, qcBelow); @@ -385,13 +385,13 @@ void AudioStats::on_Tick_timeout() { txt.sprintf("%04llums",g.uiDoublePush / 1000); qlDoublePush->setText(txt); - abSpeech->iBelow = lroundf(g.s.fVADmin * 32767.0f); - abSpeech->iAbove = lroundf(g.s.fVADmax * 32767.0f); + abSpeech->iBelow = iroundf(g.s.fVADmin * 32767.0f); + abSpeech->iAbove = iroundf(g.s.fVADmax * 32767.0f); if (g.s.vsVAD == Settings::Amplitude) { - abSpeech->iValue = lroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); + abSpeech->iValue = iroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); } else { - abSpeech->iValue = lroundf(ai->fSpeechProb * 32767.0f); + abSpeech->iValue = iroundf(ai->fSpeechProb * 32767.0f); } abSpeech->update(); diff --git a/src/mumble/AudioWizard.cpp b/src/mumble/AudioWizard.cpp index 6b6179c01..9d0657917 100644 --- a/src/mumble/AudioWizard.cpp +++ b/src/mumble/AudioWizard.cpp @@ -781,7 +781,7 @@ void AudioWizard::on_Ticker_timeout() { abVAD->iAbove = qsMaxVAD->value(); if (g.s.vsVAD == Settings::Amplitude) { - abVAD->iValue = lroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); + abVAD->iValue = iroundf((32767.f/96.0f) * (96.0f + ai->dPeakMic)); } else { abVAD->iValue = static_cast<int>(ai->fSpeechProb * 32767.0); } diff --git a/src/mumble/BanEditor.cpp b/src/mumble/BanEditor.cpp index 9ba5293c2..bf927f486 100644 --- a/src/mumble/BanEditor.cpp +++ b/src/mumble/BanEditor.cpp @@ -48,11 +48,11 @@ BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p) { quint32 v = 0; std::string s = be.address(); if (s.length() == 4) { - const char *data = s.data(); - v += (data[0] << 24); - v += (data[1] << 16); - v += (data[2] << 8); - v += (data[3] << 0); + const char *dataptr = s.data(); + v += (dataptr[0] << 24); + v += (dataptr[1] << 16); + v += (dataptr[2] << 8); + v += (dataptr[3] << 0); qlBans << ban(v, be.mask()); } } @@ -67,10 +67,10 @@ void BanEditor::accept() { foreach(const ban &b, qlBans) { MumbleProto::BanList_BanEntry *be = msg.add_bans(); char buff[4]; - buff[0] = (b.first >> 24) & 0xFF; - buff[1] = (b.first >> 16) & 0xFF; - buff[2] = (b.first >> 8) & 0xFF; - buff[3] = (b.first >> 0) & 0xFF; + buff[0] = static_cast<char>((b.first >> 24) & 0xFF); + buff[1] = static_cast<char>((b.first >> 16) & 0xFF); + buff[2] = static_cast<char>((b.first >> 8) & 0xFF); + buff[3] = static_cast<char>((b.first >> 0) & 0xFF); be->set_address(std::string(buff, 4)); be->set_mask(b.second); } diff --git a/src/mumble/Cert.cpp b/src/mumble/Cert.cpp index 638406643..fb45479e5 100644 --- a/src/mumble/Cert.cpp +++ b/src/mumble/Cert.cpp @@ -41,6 +41,8 @@ #define SSL_OUTBUF(x) x #endif +#define SSL_STRING(x) QString::fromLatin1(x).toUtf8().data() + CertView::CertView(QWidget *p) : QGroupBox(p) { QGridLayout *grid = new QGridLayout(this); QLabel *l; @@ -381,10 +383,10 @@ Settings::KeyPair CertWizard::generateNewCert(QString qsname, const QString &qse X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<unsigned char *>(qsname.toUtf8().data()), -1, -1, 0); X509_set_issuer_name(x509, name); - add_ext(x509, NID_basic_constraints, "critical,CA:FALSE"); - add_ext(x509, NID_ext_key_usage, "clientAuth"); - add_ext(x509, NID_subject_key_identifier, "hash"); - add_ext(x509, NID_netscape_comment, "Generated by Mumble"); + add_ext(x509, NID_basic_constraints, SSL_STRING("critical,CA:FALSE")); + add_ext(x509, NID_ext_key_usage, SSL_STRING("clientAuth")); + add_ext(x509, NID_subject_key_identifier, SSL_STRING("hash")); + add_ext(x509, NID_netscape_comment, SSL_STRING("Generated by Mumble")); add_ext(x509, NID_subject_alt_name, QString::fromLatin1("email:%1").arg(qsemail).toUtf8().data()); X509_sign(x509, pkey, EVP_sha1()); @@ -525,7 +527,7 @@ QByteArray CertWizard::exportCert(const Settings::KeyPair &kp) { sk_X509_push(certs, c); } - pkcs = PKCS12_create("", "Mumble Identity", pkey, x509, certs, -1, -1, 0, 0, 0); + pkcs = PKCS12_create(SSL_STRING(""), SSL_STRING("Mumble Identity"), pkey, x509, certs, -1, -1, 0, 0, 0); if (pkcs) { mem = BIO_new(BIO_s_mem()); @@ -534,7 +536,7 @@ QByteArray CertWizard::exportCert(const Settings::KeyPair &kp) { size = BIO_get_mem_data(mem, &data); - qba = QByteArray(data, size); + qba = QByteArray(data, static_cast<int>(size)); } } } diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 982046ddf..99f75e520 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -419,9 +419,9 @@ QVariant LogDocument::loadResource(int type, const QUrl &url) { void LogDocument::receivedHead() { QNetworkReply *rep = qobject_cast<QNetworkReply *>(sender()); - QVariant size = rep->header(QNetworkRequest::ContentLengthHeader); - if (size == QVariant::Invalid || size.toInt() > g.s.iMaxImageSize) { - qWarning() << "Image "<< rep->url().toString() <<" (" << size.toInt() << " byte) to big, request aborted. "; + QVariant length = rep->header(QNetworkRequest::ContentLengthHeader); + if (length == QVariant::Invalid || length.toInt() > g.s.iMaxImageSize) { + qWarning() << "Image "<< rep->url().toString() <<" (" << length.toInt() << " byte) to big, request aborted. "; rep->abort(); } } diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 71132ae9d..fa0be5fd9 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -758,6 +758,9 @@ void MainWindow::on_qaPlayerRegister_triggered() { unsigned int session = p->uiSession; if (QMessageBox::question(this, tr("Register player %1").arg(p->qsName), tr("<p>You are about to register %1 on the server. This action cannot be undone, the username cannot be changed, and as a registered user, %1 will have access to the server even if you change the server password.</p><p>From this point on, %1 will be authenticated with the certificate currently in use.</p><p>Are you sure you want to register %1?</p>").arg(p->qsName), QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes) { + p = ClientPlayer::get(session); + if (! p) + return; MumbleProto::UserState mpus; mpus.set_session(p->uiSession); mpus.set_user_id(0); diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 93c98a7cd..4d2b3eb00 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -236,7 +236,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { } if (msg.has_texture()) { const std::string &str = msg.texture(); - pDst->qbaTexture = QByteArray(str.data(), str.size()); + pDst->qbaTexture = QByteArray(str.data(), static_cast<int>(str.size())); g.o->verifyTexture(pDst); } if (msg.has_comment()) { diff --git a/src/mumble/OSS.cpp b/src/mumble/OSS.cpp index e309c467b..2b77b9448 100644 --- a/src/mumble/OSS.cpp +++ b/src/mumble/OSS.cpp @@ -245,10 +245,10 @@ void OSSInput::run() { short buffer[iMicLength]; while (bRunning) { - int len = iMicLength * iMicChannels * sizeof(short); + int len = static_cast<int>(iMicLength * iMicChannels * sizeof(short)); ssize_t l = read(fd, buffer, len); if (l != len) { - qWarning("OSSInput: Read %d", l); + qWarning("OSSInput: Read %ld", l); break; } addMic(buffer, iMicLength); @@ -342,15 +342,15 @@ void OSSOutput::run() { qWarning("OSSOutput: Staring audio playback to %s", device.constData()); - const int blocklen = iOutputBlock * iChannels * sizeof(short); + ssize_t blocklen = iOutputBlock * iChannels * sizeof(short); short mbuffer[iOutputBlock * iChannels]; while (bRunning) { bool stillRun = mix(mbuffer, iOutputBlock); if (stillRun) { - int l = write(fd, mbuffer, blocklen); + ssize_t l = write(fd, mbuffer, blocklen); if (l != blocklen) { - qWarning("OSSOutput: Write %d != %d", l, blocklen); + qWarning("OSSOutput: Write %ld != %ld", l, blocklen); break; } } else { diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp index a67db5b2a..d48b19013 100644 --- a/src/mumble/Overlay.cpp +++ b/src/mumble/Overlay.cpp @@ -60,8 +60,8 @@ void OverlayConfig::load(const Settings &r) { loadCheckBox(qcbTop, r.bOverlayTop); loadCheckBox(qcbBottom, r.bOverlayBottom); - loadSlider(qsX, static_cast<int>(lroundf(r.fOverlayX * 100.0f))); - loadSlider(qsY, 100 - static_cast<int>(lroundf(r.fOverlayY * 100.0f))); + loadSlider(qsX, iroundf(r.fOverlayX * 100.0f)); + loadSlider(qsY, 100 - iroundf(r.fOverlayY * 100.0f)); qfFont = r.qfOverlayFont; qcPlayer = r.qcOverlayPlayer; qcTalking= r.qcOverlayTalking; @@ -69,7 +69,7 @@ void OverlayConfig::load(const Settings &r) { qcChannel = r.qcOverlayChannel; qcChannelTalking = r.qcOverlayChannelTalking; qlCurrentFont->setText(qfFont.family()); - loadSlider(qsMaxHeight, static_cast<int>(lroundf(r.fOverlayHeight * 1000.0f))); + loadSlider(qsMaxHeight, iroundf(r.fOverlayHeight * 1000.0f)); setColorLabel(qlPlayer, qcPlayer); setColorLabel(qlTalking, qcTalking); setColorLabel(qlAltTalking, qcAltTalking); diff --git a/src/mumble/Overlay_unix.cpp b/src/mumble/Overlay_unix.cpp index f038b0e33..47227f6cc 100644 --- a/src/mumble/Overlay_unix.cpp +++ b/src/mumble/Overlay_unix.cpp @@ -147,5 +147,5 @@ void Overlay::setActive(bool) { void Overlay::on_Timer_timeout() { if (sm.sm) - sm.sm->lastAppAlive = time(NULL); + sm.sm->lastAppAlive = static_cast<int>(time(NULL)); } diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 7765d53c1..342ccd48f 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -42,9 +42,9 @@ #include "NetworkConfig.h" #include "OSInfo.h" -ServerHandlerMessageEvent::ServerHandlerMessageEvent(const QByteArray &msg, unsigned int type, bool flush) : QEvent(static_cast<QEvent::Type>(SERVERSEND_EVENT)) { +ServerHandlerMessageEvent::ServerHandlerMessageEvent(const QByteArray &msg, unsigned int mtype, bool flush) : QEvent(static_cast<QEvent::Type>(SERVERSEND_EVENT)) { qbaMsg = msg; - uiType = type; + uiType = mtype; bFlush = flush; } @@ -154,7 +154,7 @@ void ServerHandler::udpReady() { if (msgType == MessageHandler::UDPPing) { quint64 t; pds >> t; - accUDP((tTimestamp.elapsed() - t) / 1000.0); + accUDP(static_cast<double>(tTimestamp.elapsed() - t) / 1000.0); } else if (msgType == MessageHandler::UDPVoice) { handleVoicePacket(msgFlags, pds); } @@ -189,9 +189,9 @@ void ServerHandler::sendMessage(const char *data, int len) { qba.resize(len + 4); unsigned char *uc = reinterpret_cast<unsigned char *>(qba.data()); uc[0] = MessageHandler::UDPTunnel; - uc[1] = (len >> 16) & 0xFF; - uc[2] = (len >> 8) & 0xFF; - uc[3] = len & 0xFF; + uc[1] = static_cast<unsigned char>((len >> 16) & 0xFF); + uc[2] = static_cast<unsigned char>((len >> 8) & 0xFF); + uc[3] = static_cast<unsigned char>(len & 0xFF); memcpy(uc + 4, data, len); QApplication::postEvent(this, new ServerHandlerMessageEvent(qba, MessageHandler::UDPTunnel, true)); @@ -312,12 +312,12 @@ void ServerHandler::sendPing() { mpp.set_lost(cs.uiLost); mpp.set_resync(cs.uiResync); - mpp.set_udp_ping_avg(boost::accumulators::mean(accUDP)); - mpp.set_udp_ping_var(boost::accumulators::variance(accUDP)); - mpp.set_udp_packets(boost::accumulators::count(accUDP)); - mpp.set_tcp_ping_avg(boost::accumulators::mean(accTCP)); - mpp.set_tcp_ping_var(boost::accumulators::variance(accTCP)); - mpp.set_tcp_packets(boost::accumulators::count(accTCP)); + mpp.set_udp_ping_avg(static_cast<float>(boost::accumulators::mean(accUDP))); + mpp.set_udp_ping_var(static_cast<float>(boost::accumulators::variance(accUDP))); + mpp.set_udp_packets(static_cast<int>(boost::accumulators::count(accUDP))); + mpp.set_tcp_ping_avg(static_cast<float>(boost::accumulators::mean(accTCP))); + mpp.set_tcp_ping_var(static_cast<float>(boost::accumulators::variance(accTCP))); + mpp.set_tcp_packets(static_cast<int>(boost::accumulators::count(accTCP))); sendMessage(mpp); } @@ -327,11 +327,11 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) { if (qbaMsg.length() < 1) return; - unsigned int msgType = (ptr[0] >> 5) & 0x7; + unsigned int msgUDPType = (ptr[0] >> 5) & 0x7; unsigned int msgFlags = ptr[0] & 0x1f; PacketDataStream pds(qbaMsg.constData() + 1, qbaMsg.size()); - if (msgType == MessageHandler::UDPVoice) { + if (msgUDPType == MessageHandler::UDPVoice) { handleVoicePacket(msgFlags, pds); } } else if (msgType == MessageHandler::Ping) { @@ -342,7 +342,7 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) { cs.uiRemoteLate = msg.late(); cs.uiRemoteLost = msg.lost(); cs.uiRemoteResync = msg.resync(); - accTCP((g.sh->tTimestamp.elapsed() - msg.timestamp()) / 1000.0); + accTCP(static_cast<double>(g.sh->tTimestamp.elapsed() - msg.timestamp()) / 1000.0); } } else { ServerHandlerMessageEvent *shme=new ServerHandlerMessageEvent(qbaMsg, msgType, false); diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp index 7f41af0ed..3ae9eaadb 100644 --- a/src/mumble/mumble_pch.hpp +++ b/src/mumble/mumble_pch.hpp @@ -92,4 +92,6 @@ typedef WId HWND; #include <mmintrin.h> #endif +#define iroundf(x) ( static_cast<int>(x) ) + #endif diff --git a/src/murmur/Cert.cpp b/src/murmur/Cert.cpp index 1cc1bc74a..b16e1677c 100644 --- a/src/murmur/Cert.cpp +++ b/src/murmur/Cert.cpp @@ -31,6 +31,8 @@ #include "Server.h" #include "Meta.h" +#define SSL_STRING(x) QString::fromLatin1(x).toUtf8().data() + static int add_ext(X509 * crt, int nid, char *value) { X509_EXTENSION *ex; X509V3_CTX ctx; @@ -118,10 +120,10 @@ void Server::initializeCert() { X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<unsigned char *>(const_cast<char *>("Murmur Autogenerated Certificate v2")), -1, -1, 0); X509_set_issuer_name(x509, name); - add_ext(x509, NID_basic_constraints, "critical,CA:FALSE"); - add_ext(x509, NID_ext_key_usage, "serverAuth,clientAuth"); - add_ext(x509, NID_subject_key_identifier, "hash"); - add_ext(x509, NID_netscape_comment, "Generated from murmur"); + add_ext(x509, NID_basic_constraints, SSL_STRING("critical,CA:FALSE")); + add_ext(x509, NID_ext_key_usage, SSL_STRING("serverAuth,clientAuth")); + add_ext(x509, NID_subject_key_identifier, SSL_STRING("hash")); + add_ext(x509, NID_netscape_comment, SSL_STRING("Generated from murmur")); X509_sign(x509, pkey, EVP_sha1()); diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index d55b23acb..159f7d012 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -307,10 +307,10 @@ void Server::msgBanList(User *uSource, MumbleProto::BanList &msg) { foreach(const ban &b, qlBans) { MumbleProto::BanList_BanEntry *be = msg.add_bans(); char buff[4]; - buff[0] = (b.first >> 24) & 0xFF; - buff[1] = (b.first >> 16) & 0xFF; - buff[2] = (b.first >> 8) & 0xFF; - buff[3] = (b.first >> 0) & 0xFF; + buff[0] = static_cast<char>((b.first >> 24) & 0xFF); + buff[1] = static_cast<char>((b.first >> 16) & 0xFF); + buff[2] = static_cast<char>((b.first >> 8) & 0xFF); + buff[3] = static_cast<char>((b.first >> 0) & 0xFF); be->set_address(std::string(buff, 4)); be->set_mask(b.second); } @@ -348,7 +348,7 @@ void Server::msgUDPTunnel(User *uSource, MumbleProto::UDPTunnel &msg) { MSG_SETUP(Player::Authenticated); const std::string &str = msg.packet(); - int len = str.length(); + int len = static_cast<int>(str.length()); if (len < 1) return; QReadLocker rl(&qrwlUsers); @@ -842,8 +842,7 @@ void Server::msgACL(User *uSource, MumbleProto::ACL &msg) { p = c->cParent; QSet<QString> allnames=Group::groupNames(c); - QString name; - foreach(name, allnames) { + foreach(const QString &name, allnames) { Group *g = c->qhGroups.value(name); Group *pg = p ? Group::getGroup(p, name) : NULL; @@ -873,10 +872,10 @@ void Server::msgACL(User *uSource, MumbleProto::ACL &msg) { MumbleProto::QueryUsers mpqu; foreach(int id, qsId) { - QString name=getUserName(id); - if (! name.isEmpty()) { + QString uname=getUserName(id); + if (! uname.isEmpty()) { mpqu.add_ids(id); - mpqu.add_names(u8(name)); + mpqu.add_names(u8(uname)); } } if (mpqu.ids_size()) diff --git a/src/murmur/MurmurIce.cpp b/src/murmur/MurmurIce.cpp index 918eb81fb..85c88e37c 100644 --- a/src/murmur/MurmurIce.cpp +++ b/src/murmur/MurmurIce.cpp @@ -444,7 +444,7 @@ void MurmurIce::idToTextureSlot(QByteArray &qba, int id) { try { const ::Murmur::Texture &tex = prx->idToTexture(id); - qba.resize(tex.size()); + qba.resize(static_cast<int>(tex.size())); char *ptr = qba.data(); for (unsigned int i=0;i<tex.size();++i) ptr[i] = tex[i]; @@ -1258,7 +1258,7 @@ static void impl_Server_setTexture(const ::Murmur::AMD_Server_setTexturePtr cb, return; } - QByteArray qba(tex.size(), 0); + QByteArray qba(static_cast<int>(tex.size()), 0); char *ptr = qba.data(); for (unsigned int i=0;i<tex.size();++i) ptr[i] = tex[i]; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 9bc39d292..33d912ed9 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -369,7 +369,7 @@ void Server::run() { #ifdef Q_OS_WIN len=::recvfrom(sUdpSocket, encrypt, 512, 0, reinterpret_cast<struct sockaddr *>(&from), &fromlen); #else - len=::recvfrom(sUdpSocket, encrypt, 512, MSG_TRUNC, reinterpret_cast<struct sockaddr *>(&from), &fromlen); + len=static_cast<qint32>(::recvfrom(sUdpSocket, encrypt, 512, MSG_TRUNC, reinterpret_cast<struct sockaddr *>(&from), &fromlen)); #endif if (len == 0) { break; @@ -508,7 +508,7 @@ void Server::processMsg(User *u, const char *data, int len) { poslen = pdi.left(); - buffer[0] = target; + buffer[0] = static_cast<char>(target); pds << u->uiSession; pds.append(data + 1, len - 1); @@ -778,9 +778,9 @@ void Server::tcpTransmitData(QByteArray a, unsigned int id) { qba.resize(len + 4); unsigned char *uc = reinterpret_cast<unsigned char *>(qba.data()); uc[0] = MessageHandler::UDPTunnel; - uc[1] = (len >> 16) & 0xFF; - uc[2] = (len >> 8) & 0xFF; - uc[3] = len & 0xFF; + uc[1] = static_cast<unsigned char>((len >> 16) & 0xFF); + uc[2] = static_cast<unsigned char>((len >> 8) & 0xFF); + uc[3] = static_cast<unsigned char>(len & 0xFF); memcpy(uc + 4, a.constData(), len); c->sendMessage(qba); diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp index 55039ef8d..92c08cfa8 100644 --- a/src/murmur/ServerDB.cpp +++ b/src/murmur/ServerDB.cpp @@ -812,10 +812,10 @@ bool Server::setTexture(int id, const QByteArray &texture) { tex = qUncompress(texture); } else { QByteArray qba(4,0); - qba[0] = (l >> 24) & 0xFF; - qba[1] = (l >> 16) & 0xFF; - qba[2] = (l >> 8) & 0xFF; - qba[3] = (l >> 0) & 0xFF; + qba[0] = static_cast<char>((l >> 24) & 0xFF); + qba[1] = static_cast<char>((l >> 16) & 0xFF); + qba[2] = static_cast<char>((l >> 8) & 0xFF); + qba[3] = static_cast<char>((l >> 0) & 0xFF); qba.append(texture); tex = qUncompress(qba); } diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index f76d83e0d..5772ce72f 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -277,7 +277,7 @@ void UnixMurmur::finalcap() { if (getrlimit(RLIMIT_RTPRIO, &r) != 0) { qCritical("Failed to get priority limits."); } else { - qWarning("Was %d %d", r.rlim_cur, r.rlim_max); + qWarning("Resource limits were %ld %ld", r.rlim_cur, r.rlim_max); r.rlim_cur = r.rlim_max = 1; if (setrlimit(RLIMIT_RTPRIO, &r) != 0) { qCritical("Failed to set priority limits."); |