From 2786eadaf9aa56843f5a0b1087c80d7c28c0c386 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 26 Aug 2013 14:58:23 +0100 Subject: [PATCH] Removed a few pedantic warnings. --- extras/JuceDemo/JuceLibraryCode/AppConfig.h | 2 +- .../Source/demos/AudioDemoRecordPage.cpp | 2 +- .../Source/demos/RenderingTestComponent.cpp | 4 +- .../JuceDemo/Source/demos/ThreadingDemo.cpp | 2 +- extras/JuceDemo/Source/demos/TreeViewDemo.cpp | 2 +- extras/JuceDemo/Source/demos/WidgetsDemo.cpp | 2 +- .../buffers/juce_AudioSampleBuffer.cpp | 6 +- .../buffers/juce_FloatVectorOperations.cpp | 6 +- .../effects/juce_LagrangeInterpolator.cpp | 2 +- .../juce_audio_basics/juce_audio_basics.cpp | 7 +- .../codecs/juce_AiffAudioFormat.cpp | 22 ++- .../codecs/juce_CoreAudioFormat.cpp | 34 ++-- .../codecs/juce_MP3AudioFormat.cpp | 179 +++++++++--------- .../codecs/juce_OggVorbisAudioFormat.cpp | 8 +- .../codecs/juce_WavAudioFormat.cpp | 21 +- .../juce_BufferingAudioFormatReader.cpp | 4 +- .../juce_MemoryMappedAudioFormatReader.h | 2 +- .../players/juce_AudioProcessorPlayer.cpp | 2 +- modules/juce_core/containers/juce_Variant.cpp | 4 +- modules/juce_core/files/juce_File.cpp | 2 +- modules/juce_core/files/juce_File.h | 2 +- .../juce_core/files/juce_FileOutputStream.cpp | 6 +- .../juce_core/files/juce_FileOutputStream.h | 2 +- modules/juce_core/memory/juce_MemoryBlock.cpp | 52 ++--- .../juce_core/native/juce_posix_SharedCode.h | 2 +- modules/juce_core/network/juce_IPAddress.cpp | 6 +- .../juce_core/streams/juce_OutputStream.cpp | 8 +- modules/juce_core/xml/juce_XmlElement.cpp | 8 +- .../zip/juce_GZIPCompressorOutputStream.cpp | 2 +- .../native/juce_mac_CoreGraphicsContext.mm | 25 +-- .../juce_graphics/native/juce_mac_Fonts.mm | 2 +- .../native/juce_mac_MouseCursor.mm | 1 + .../juce_opengl/opengl/juce_OpenGLContext.cpp | 7 +- .../opengl/juce_OpenGLGraphicsContext.cpp | 26 +-- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 10 +- 35 files changed, 235 insertions(+), 237 deletions(-) diff --git a/extras/JuceDemo/JuceLibraryCode/AppConfig.h b/extras/JuceDemo/JuceLibraryCode/AppConfig.h index 8d45ce5251..0a36714512 100644 --- a/extras/JuceDemo/JuceLibraryCode/AppConfig.h +++ b/extras/JuceDemo/JuceLibraryCode/AppConfig.h @@ -84,7 +84,7 @@ #endif #ifndef JUCE_USE_MP3AUDIOFORMAT - //#define JUCE_USE_MP3AUDIOFORMAT + #define JUCE_USE_MP3AUDIOFORMAT 1 #endif #ifndef JUCE_USE_LAME_AUDIO_FORMAT diff --git a/extras/JuceDemo/Source/demos/AudioDemoRecordPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoRecordPage.cpp index dcfd36a46a..d2f1bd4739 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoRecordPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoRecordPage.cpp @@ -120,7 +120,7 @@ public: // We need to clear the output buffers, in case they're full of junk.. for (int i = 0; i < numOutputChannels; ++i) if (outputChannelData[i] != 0) - zeromem (outputChannelData[i], sizeof (float) * numSamples); + zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples); } private: diff --git a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp index fc1eaf9147..0dbb3a04b1 100644 --- a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp +++ b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp @@ -36,8 +36,8 @@ public: averageFPS = 0; lastPaintTime = 0; - rgbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoJpeg_jpg, RenderingTestComponent::demoJpeg_jpgSize); - argbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoPng_png, RenderingTestComponent::demoPng_pngSize); + rgbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoJpeg_jpg, (size_t) RenderingTestComponent::demoJpeg_jpgSize); + argbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoPng_png, (size_t) RenderingTestComponent::demoPng_pngSize); createSVGDrawable(); glyphs.addFittedText (Font (20.0f), "The Quick Brown Fox Jumped Over The Lazy Dog", diff --git a/extras/JuceDemo/Source/demos/ThreadingDemo.cpp b/extras/JuceDemo/Source/demos/ThreadingDemo.cpp index 0586d3bfbb..0e14bf701b 100644 --- a/extras/JuceDemo/Source/demos/ThreadingDemo.cpp +++ b/extras/JuceDemo/Source/demos/ThreadingDemo.cpp @@ -49,7 +49,7 @@ public: size = Random::getSystemRandom().nextFloat() * 30.0f + 30.0f; - colour = Colour (Random::getSystemRandom().nextInt()) + colour = Colour ((uint32) Random::getSystemRandom().nextInt()) .withAlpha (0.5f) .withBrightness (0.7f); } diff --git a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp index e90a1a657e..287b470819 100644 --- a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp +++ b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp @@ -56,7 +56,7 @@ public: g.fillAll (Colours::blue.withAlpha (0.3f)); // use a "colour" attribute in the xml tag for this node to set the text colour.. - g.setColour (Colour (xml.getStringAttribute ("colour", "ff000000").getHexValue32())); + g.setColour (Colour ((uint32) xml.getStringAttribute ("colour", "ff000000").getHexValue32())); g.setFont (height * 0.7f); diff --git a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp index 8e00585731..07b21a361b 100644 --- a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp +++ b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp @@ -43,7 +43,7 @@ public: direction.x = random.nextFloat() * 8.0f - 4.0f; direction.y = random.nextFloat() * 8.0f - 4.0f; - colour = Colour (random.nextInt()) + colour = Colour ((uint32) random.nextInt()) .withAlpha (0.5f) .withBrightness (0.7f); diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp index ab670ae1a4..1dd3e3c28e 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp @@ -158,8 +158,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels, if (newNumSamples != size || newNumChannels != numChannels) { - const size_t allocatedSamplesPerChannel = (newNumSamples + 3) & ~3; - const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15; + const size_t allocatedSamplesPerChannel = ((size_t) newNumSamples + 3) & ~3u; + const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15u; const size_t newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (float)) + channelListSize + 32; @@ -168,7 +168,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, HeapBlock newData; newData.allocate (newTotalBytes, clearExtraSpace); - const size_t numSamplesToCopy = jmin (newNumSamples, size); + const size_t numSamplesToCopy = (size_t) jmin (newNumSamples, size); float** const newChannels = reinterpret_cast (newData.getData()); float* newChan = reinterpret_cast (newData + channelListSize); diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 37b408f9d6..d863ba9311 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -162,7 +162,7 @@ namespace FloatVectorHelpers void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept { #if JUCE_USE_VDSP_FRAMEWORK - vDSP_vclr (dest, 1, num); + vDSP_vclr (dest, 1, (size_t) num); #else zeromem (dest, num * sizeof (float)); #endif @@ -171,7 +171,7 @@ void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, int num) noexcept { #if JUCE_USE_VDSP_FRAMEWORK - vDSP_vfill (&valueToFill, dest, 1, num); + vDSP_vfill (&valueToFill, dest, 1, (size_t) num); #else #if JUCE_USE_SSE_INTRINSICS const __m128 val = _mm_load1_ps (&valueToFill); @@ -183,7 +183,7 @@ void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, void JUCE_CALLTYPE FloatVectorOperations::copy (float* dest, const float* src, int num) noexcept { - memcpy (dest, src, num * sizeof (float)); + memcpy (dest, src, (size_t) num * sizeof (float)); } void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index 664996080b..7bab3a576f 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp @@ -83,7 +83,7 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in, { if (actualRatio == 1.0) { - memcpy (out, in, numOut * sizeof (float)); + memcpy (out, in, (size_t) numOut * sizeof (float)); if (numOut >= 4) { diff --git a/modules/juce_audio_basics/juce_audio_basics.cpp b/modules/juce_audio_basics/juce_audio_basics.cpp index 0726b6e8b2..210cbfd0a9 100644 --- a/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/modules/juce_audio_basics/juce_audio_basics.cpp @@ -48,9 +48,14 @@ #include #endif -#if JUCE_MAC || JUCE_IOS +#ifndef JUCE_USE_VDSP_FRAMEWORK #define JUCE_USE_VDSP_FRAMEWORK 1 +#endif + +#if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK #include +#else + #undef JUCE_USE_VDSP_FRAMEWORK #endif namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index cc5f1025b5..33ea822955 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -137,13 +137,13 @@ namespace AiffFileHelpers { zerostruct (*this); - flags = input.readIntBigEndian(); - numBeats = input.readIntBigEndian(); - rootNote = input.readShortBigEndian(); - key = input.readShortBigEndian(); - timeSigNum = input.readShortBigEndian(); - timeSigDen = input.readShortBigEndian(); - oneShot = input.readShortBigEndian(); + flags = (uint32) input.readIntBigEndian(); + numBeats = (uint32) input.readIntBigEndian(); + rootNote = (uint16) input.readShortBigEndian(); + key = (uint16) input.readShortBigEndian(); + timeSigNum = (uint16) input.readShortBigEndian(); + timeSigDen = (uint16) input.readShortBigEndian(); + oneShot = (uint16) input.readShortBigEndian(); input.read (unknown, sizeof (unknown)); } @@ -199,7 +199,7 @@ namespace AiffFileHelpers { MemoryBlock mb; input.skipNextBytes (4); - input.readIntoMemoryBlock (mb, length - 4); + input.readIntoMemoryBlock (mb, (ssize_t) length - 4); static const char* appleGenres[] = { @@ -910,8 +910,10 @@ bool AiffAudioFormat::canHandleFile (const File& f) return true; const OSType type = f.getMacOSType(); - return type == 'AIFF' || type == 'AIFC' - || type == 'aiff' || type == 'aifc'; + + // (NB: written as hex to avoid four-char-constant warnings) + return type == 0x41494646 /* AIFF */ || type == 0x41494643 /* AIFC */ + || type == 0x61696666 /* aiff */ || type == 0x61696663 /* aifc */; } #endif diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 2efe1294c5..d36d162b1e 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -64,9 +64,9 @@ struct CoreAudioFormatMetatdata { FileHeader (InputStream& input) { - fileType = input.readIntBigEndian(); - fileVersion = input.readShortBigEndian(); - fileFlags = input.readShortBigEndian(); + fileType = (uint32) input.readIntBigEndian(); + fileVersion = (uint16) input.readShortBigEndian(); + fileFlags = (uint16) input.readShortBigEndian(); } uint32 fileType; @@ -79,8 +79,8 @@ struct CoreAudioFormatMetatdata { ChunkHeader (InputStream& input) { - chunkType = input.readIntBigEndian(); - chunkSize = input.readInt64BigEndian(); + chunkType = (uint32) input.readIntBigEndian(); + chunkSize = (int64) input.readInt64BigEndian(); } uint32 chunkType; @@ -93,12 +93,12 @@ struct CoreAudioFormatMetatdata AudioDescriptionChunk (InputStream& input) { sampleRate = input.readDoubleBigEndian(); - formatID = input.readIntBigEndian(); - formatFlags = input.readIntBigEndian(); - bytesPerPacket = input.readIntBigEndian(); - framesPerPacket = input.readIntBigEndian(); - channelsPerFrame = input.readIntBigEndian(); - bitsPerChannel = input.readIntBigEndian(); + formatID = (uint32) input.readIntBigEndian(); + formatFlags = (uint32) input.readIntBigEndian(); + bytesPerPacket = (uint32) input.readIntBigEndian(); + framesPerPacket = (uint32) input.readIntBigEndian(); + channelsPerFrame = (uint32) input.readIntBigEndian(); + bitsPerChannel = (uint32) input.readIntBigEndian(); } double sampleRate; @@ -478,12 +478,12 @@ AudioFormatReader* CoreAudioFormat::createReaderFor (InputStream* sourceStream, return nullptr; } -AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream* streamToWriteTo, - double sampleRateToUse, - unsigned int numberOfChannels, - int bitsPerSample, - const StringPairArray& metadataValues, - int qualityOptionIndex) +AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream*, + double /*sampleRateToUse*/, + unsigned int /*numberOfChannels*/, + int /*bitsPerSample*/, + const StringPairArray& /*metadataValues*/, + int /*qualityOptionIndex*/) { jassertfalse; // not yet implemented! return nullptr; diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index 1b4c6bf5a7..b2589cd471 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -436,14 +436,15 @@ struct VBRTagData vbrScale = -1; if (flags & 8) - vbrScale = ByteOrder::bigEndianInt (data); + vbrScale = (int) ByteOrder::bigEndianInt (data); headersize = ((type + 1) * 72000 * bitrate) / sampleRate; return true; } uint8 toc[100]; - int sampleRate, flags, frames, bytes, vbrScale, headersize; + int sampleRate, vbrScale, headersize; + unsigned int flags, frames, bytes; private: static bool isVbrTag (const uint8* const d) noexcept @@ -492,7 +493,7 @@ struct MP3Frame mpeg25 = (header & (1 << 20)) == 0; lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1); layer = 4 - ((header >> 17) & 3); - sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3)); + sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : ((int) ((header >> 10) & 3) + (lsf * 3)); crc16FollowsHeader = ((header >> 16) & 1) == 0; bitrateIndex = (header >> 12) & 15; padding = (header >> 9) & 1; @@ -545,13 +546,13 @@ struct Constants initLayer3Tables(); } - const uint8* getGroupTable (const int16 d1, const int index) const noexcept + const uint8* getGroupTable (const int16 d1, const uint32 index) const noexcept { switch (d1) { - case 3: return &group3tab [3 * jmin (index, 3 * 3 * 3)]; - case 5: return &group5tab [3 * jmin (index, 5 * 5 * 5)]; - case 9: return &group9tab [3 * jmin (index, 9 * 9 * 9)]; + case 3: return &group3tab [3 * jmin (index, 3u * 3u * 3u)]; + case 5: return &group5tab [3 * jmin (index, 5u * 5u * 5u)]; + case 9: return &group9tab [3 * jmin (index, 9u * 9u * 9u)]; default: break; } @@ -808,7 +809,7 @@ private: for (int k = 0; k < 6; ++k) { const int n = k + j * 6 + i * 36; - iLength2[n] = i | (j << 3) | (k << 6) | (3 << 12); + iLength2[n] = (unsigned int) (i | (j << 3) | (k << 6) | (3 << 12)); } for (i = 0; i < 4; ++i) @@ -816,15 +817,15 @@ private: for (int k = 0; k < 4; ++k) { const int n = k + j * 4 + i * 16; - iLength2[n + 180] = i | (j << 3) | (k << 6) | (4 << 12); + iLength2[n + 180] = (unsigned int) (i | (j << 3) | (k << 6) | (4 << 12)); } for (i = 0; i < 4; ++i) for (j = 0; j < 3; ++j) { const int n = j + i * 3; - iLength2[n + 244] = i | (j << 3) | (5 << 12); - nLength2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15); + iLength2[n + 244] = (unsigned int) (i | (j << 3) | (5 << 12)); + nLength2[n + 500] = (unsigned int) (i | (j << 3) | (2 << 12) | (1 << 15)); } for (i = 0; i < 5; ++i) @@ -833,7 +834,7 @@ private: for (int l = 0; l < 4; ++l) { const int n = l + k * 4 + j * 16 + i * 80; - nLength2[n] = i | (j << 3) | (k << 6) | (l << 9) | (0 << 12); + nLength2[n] = (unsigned int) (i | (j << 3) | (k << 6) | (l << 9) | (0 << 12)); } for (i = 0; i < 5; ++i) @@ -841,7 +842,7 @@ private: for (int k = 0; k < 4; ++k) { const int n = k + j * 4 + i * 20; - nLength2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12); + nLength2[n + 400] = (unsigned int) (i | (j << 3) | (k << 6) | (1 << 12)); } } }; @@ -867,7 +868,7 @@ struct Layer3SideInfo sb = 1; } else - sb = maxb - 1; + sb = (int) maxb - 1; for (; sb != 0; --sb, xr1 += 10) { @@ -923,9 +924,9 @@ struct Layer3SideInfo { bool doL = mixedBlockFlag != 0; - for (int lwin = 0; lwin < 3; ++lwin) + for (uint32 lwin = 0; lwin < 3; ++lwin) { - int sfb = maxBand[lwin]; + uint32 sfb = maxBand[lwin]; doL = doL && (sfb <= 3); for (; sfb < 12; ++sfb) @@ -936,7 +937,7 @@ struct Layer3SideInfo const float t1 = tabl1[p]; const float t2 = tabl2[p]; int sb = bi.shortDiff[sfb]; - int index = sb + lwin; + uint32 index = (uint32) sb + lwin; for (; sb > 0; --sb, index += 3) { @@ -954,7 +955,7 @@ struct Layer3SideInfo const float t1 = tabl1[p]; const float t2 = tabl2[p]; int sb = bi.shortDiff[12]; - int index = sb + lwin; + uint32 index = (uint32) sb + lwin; for (; sb > 0; --sb, index += 3) { @@ -969,7 +970,7 @@ struct Layer3SideInfo { int index = bi.longIndex[maxBandl]; - for (int sfb = maxBandl; sfb < 8; ++sfb) + for (uint32 sfb = maxBandl; sfb < 8; ++sfb) { int sb = bi.longDiff[sfb]; const int p = scaleFactors[sfb]; @@ -995,7 +996,7 @@ struct Layer3SideInfo { int index = bi.longIndex[maxBandl]; - for (int sfb = maxBandl; sfb < 21; ++sfb) + for (uint32 sfb = maxBandl; sfb < 21; ++sfb) { int sb = bi.longDiff[sfb]; const int p = scaleFactors[sfb]; @@ -1081,7 +1082,7 @@ namespace DCT dct36_0 (v, ts, out1, out2, wintab, tmp2a - tmp1a, (tmp2b - tmp1b) * cos36[v]); } - void dct36 (float* const in, float* const out1, float* const out2, const float* const wintab, float* const ts) noexcept + static void dct36 (float* const in, float* const out1, float* const out2, const float* const wintab, float* const ts) noexcept { in[17] += in[16]; in[16] += in[15]; in[15] += in[14]; in[14] += in[13]; in[13] += in[12]; in[12] += in[11]; in[11] += in[10]; in[10] += in[9]; in[9] += in[8]; in[8] += in[7]; @@ -1163,7 +1164,7 @@ namespace DCT } }; - void dct12 (const float* in, float* const out1, float* const out2, const float* wi, float* ts) noexcept + static void dct12 (const float* in, float* const out1, float* const out2, const float* wi, float* ts) noexcept { { ts[0] = out1[0]; @@ -1250,7 +1251,7 @@ namespace DCT } } - void dct64 (float* const out0, float* const out1, float* const b1, float* const b2, const float* const samples) noexcept + static void dct64 (float* const out0, float* const out1, float* const b1, float* const b2, const float* const samples) noexcept { { const float* const costab = constants.cosTables[0]; @@ -1376,7 +1377,7 @@ namespace DCT out1[0x10 * 13] = b1[0x17] + b1[0x1F]; out1[0x10 * 15] = b1[0x1F]; } - void dct64 (float* const a, float* const b, const float* const c) noexcept + static void dct64 (float* const a, float* const b, const float* const c) noexcept { float temp[64]; dct64 (a, b, temp, temp + 32, c); @@ -1436,7 +1437,7 @@ struct MP3Stream lastFrameSize += nextFrameOffset; } - frame.decodeHeader (stream.readIntBigEndian()); + frame.decodeHeader ((uint32) stream.readIntBigEndian()); headerParsed = true; frameSize = frame.frameSize; isFreeFormat = (frameSize == 0); @@ -1707,14 +1708,14 @@ private: if (! checkTypeAgainstLastFrame) break; - const bool mpeg25 = (header & (1 << 20)) == 0; - const int lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1); - const int sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3)); - const int mode = (header >> 6) & 3; - const int numChannels = (mode == 3) ? 1 : 2; + const bool mpeg25 = (header & (1 << 20)) == 0; + const uint32 lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1); + const uint32 sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3)); + const uint32 mode = (header >> 6) & 3; + const uint32 numChannels = (mode == 3) ? 1 : 2; - if (numChannels == frame.numChannels && lsf == frame.lsf - && mpeg25 == frame.mpeg25 && sampleRateIndex == frame.sampleRateIndex) + if (numChannels == (uint32) frame.numChannels && lsf == (uint32) frame.lsf + && mpeg25 == frame.mpeg25 && sampleRateIndex == (uint32) frame.sampleRateIndex) break; } @@ -1743,7 +1744,7 @@ private: if (vbrHeaderFound) { - numFrames = vbrTagData.frames; + numFrames = (int) vbrTagData.frames; oldPos += jmax (vbrTagData.headersize, 1); } @@ -1914,7 +1915,7 @@ private: for (int ch = 0; ch < numChannels; ++ch) databits += sideinfo.ch[ch].gr[gr].part2_3Length; - return databits - 8 * sideinfo.mainDataStart; + return databits - 8 * (int) sideinfo.mainDataStart; } void layer1Step1 (SideInfoLayer1& si) noexcept @@ -1969,7 +1970,7 @@ private: if (n > 0) { - const uint32 w = ((-1 << n) + getBitsUint16 (n + 1) + 1); + const uint32 w = ((uint32) (-1 << n) + getBitsUint16 (n + 1) + 1); fraction[0][i] = (float) (w * constants.muls[n + 1][si.scaleFactor[i][0]]); fraction[1][i] = (float) (w * constants.muls[n + 1][si.scaleFactor[i][1]]); } @@ -2098,9 +2099,9 @@ private: if (d1 < 0) { const double cm = constants.muls[k][x1]; - fraction[ch][0][i] = (float) ((getBits (k) + d1) * cm); - fraction[ch][1][i] = (float) ((getBits (k) + d1) * cm); - fraction[ch][2][i] = (float) ((getBits (k) + d1) * cm); + fraction[ch][0][i] = (float) (((int) getBits (k) + d1) * cm); + fraction[ch][1][i] = (float) (((int) getBits (k) + d1) * cm); + fraction[ch][2][i] = (float) (((int) getBits (k) + d1) * cm); } else { @@ -2133,9 +2134,9 @@ private: if (d1 < 0) { - const int v0 = getBits (k); - const int v1 = getBits (k); - const int v2 = getBits (k); + const int v0 = (int) getBits (k); + const int v1 = (int) getBits (k); + const int v2 = (int) getBits (k); for (int ch = 0; ch < frame.numChannels; ++ch) { @@ -2184,7 +2185,7 @@ private: for (int ch = 0; ch < stereo; ++ch) { sideinfo.ch[ch].gr[0].scfsi = -1; - sideinfo.ch[ch].gr[1].scfsi = getBitsUnchecked (4); + sideinfo.ch[ch].gr[1].scfsi = (int) getBitsUnchecked (4); } for (int gr = 0; gr < 2; ++gr) @@ -2194,9 +2195,9 @@ private: Layer3SideInfo::Info& granule = sideinfo.ch[ch].gr[gr]; granule.part2_3Length = getBits (12); - granule.bigValues = jmin (288, (int) getBitsUnchecked (9)); + granule.bigValues = jmin (288u, getBitsUnchecked (9)); - const int qss = getBitsUnchecked (8); + const int qss = (int) getBitsUnchecked (8); granule.pow2gain = constants.powToGains + 256 - qss + powdiff; if (msStereo) @@ -2214,7 +2215,7 @@ private: for (int i = 0; i < 3; ++i) { - const int sbg = (getBitsUnchecked (3) << 3); + const uint32 sbg = (getBitsUnchecked (3) << 3); granule.fullGain[i] = granule.pow2gain + sbg; } @@ -2226,13 +2227,13 @@ private: for (int i = 0; i < 3; ++i) granule.tableSelect[i] = getBitsUnchecked (5); - const int r0c = getBitsUnchecked (4); - const int r1c = getBitsUnchecked (3); + const int r0c = (int) getBitsUnchecked (4); + const int r1c = (int) getBitsUnchecked (3); const int region0index = jmin (22, r0c + 1); const int region1index = jmin (22, r0c + 1 + r1c + 1); - granule.region1Start = bandInfo[sampleRate].longIndex[region0index] >> 1; - granule.region2Start = bandInfo[sampleRate].longIndex[region1index] >> 1; + granule.region1Start = (uint32) (bandInfo[sampleRate].longIndex[region0index] >> 1); + granule.region2Start = (uint32) (bandInfo[sampleRate].longIndex[region1index] >> 1); granule.blockType = 0; granule.mixedBlockFlag = 0; } @@ -2255,7 +2256,7 @@ private: Layer3SideInfo::Info& granule = sideinfo.ch[ch].gr[0]; granule.part2_3Length = getBits (12); - granule.bigValues = jmin (288, (int) getBitsUnchecked (9)); + granule.bigValues = jmin (288u, getBitsUnchecked (9)); const uint32 qss = getBitsUnchecked (8); granule.pow2gain = constants.powToGains + 256 - qss + powdiff; @@ -2294,13 +2295,13 @@ private: for (int i = 0; i < 3; ++i) granule.tableSelect[i] = getBitsUnchecked (5); - const int r0c = getBitsUnchecked (4); - const int r1c = getBitsUnchecked (3); + const int r0c = (int) getBitsUnchecked (4); + const int r1c = (int) getBitsUnchecked (3); const int region0index = jmin (22, r0c + 1); const int region1index = jmin (22, r0c + 1 + r1c + 1); - granule.region1Start = bandInfo[sampleRate].longIndex[region0index] >> 1; - granule.region2Start = bandInfo[sampleRate].longIndex[region1index] >> 1; + granule.region1Start = (uint32) (bandInfo[sampleRate].longIndex[region0index] >> 1); + granule.region2Start = (uint32) (bandInfo[sampleRate].longIndex[region1index] >> 1); granule.blockType = 0; granule.mixedBlockFlag = 0; } @@ -2328,13 +2329,13 @@ private: if (granule.mixedBlockFlag) { - for (int j = 8; --j >= 0;) *scf++ = getBitsUnchecked (num0); + for (int j = 8; --j >= 0;) *scf++ = (int) getBitsUnchecked (num0); numBits -= num0; i = 9; } - for (; --i >= 0;) *scf++ = getBitsUnchecked (num0); - for (i = 18; --i >= 0;) *scf++ = getBitsUnchecked (num1); + for (; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0); + for (i = 18; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1); *scf++ = 0; *scf++ = 0; @@ -2346,8 +2347,8 @@ private: if (scfsi < 0) { - for (int i = 11; --i >= 0;) *scf++ = getBitsUnchecked (num0); - for (int j = 10; --j >= 0;) *scf++ = getBitsUnchecked (num1); + for (int i = 11; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0); + for (int j = 10; --j >= 0;) *scf++ = (int) getBitsUnchecked (num1); numBits = (num0 + num1) * 10 + num0; } else @@ -2355,7 +2356,7 @@ private: numBits = 0; if ((scfsi & 8) == 0) { - for (int i = 6; --i >= 0;) *scf++ = getBitsUnchecked (num0); + for (int i = 6; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0); numBits += num0 * 6; } else @@ -2363,7 +2364,7 @@ private: if ((scfsi & 4) == 0) { - for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num0); + for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0); numBits += num0 * 5; } else @@ -2371,7 +2372,7 @@ private: if ((scfsi & 2) == 0) { - for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num1); + for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1); numBits += num1 * 5; } else @@ -2379,7 +2380,7 @@ private: if ((scfsi & 1) == 0) { - for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num1); + for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1); numBits += num1 * 5; } else @@ -2425,7 +2426,7 @@ private: if (num) { for (int j = 0; j < (int) (data[i]); ++j) - *scf++ = getBitsUnchecked (num); + *scf++ = (int) getBitsUnchecked (num); numBits += data[i] * num; } @@ -2445,15 +2446,15 @@ private: bool layer3DequantizeSample (float xr[32][18], int* scf, Layer3SideInfo::Info& granule, int sampleRate, int part2bits) noexcept { - const int shift = 1 + granule.scaleFactorScale; + const uint32 shift = 1 + granule.scaleFactorScale; float* xrpnt = (float*) xr; - int part2remain = granule.part2_3Length - part2bits; + int part2remain = (int) granule.part2_3Length - part2bits; - zeromem (xrpnt, sizeof (float) * (&xr[32][0] - xrpnt)); + zeromem (xrpnt, sizeof (float) * (size_t) (&xr[32][0] - xrpnt)); - const int bv = granule.bigValues; - const int region1 = granule.region1Start; - const int region2 = granule.region2Start; + const int bv = (int) granule.bigValues; + const int region1 = (int) granule.region1Start; + const int region2 = (int) granule.region2Start; int l3 = ((576 >> 1) - bv) >> 1; int l[3]; @@ -2657,14 +2658,14 @@ private: *xrpnt = 0; xrpnt += step; } - granule.maxBand[0] = max[0] + 1; - granule.maxBand[1] = max[1] + 1; - granule.maxBand[2] = max[2] + 1; - granule.maxBandl = max[3] + 1; + granule.maxBand[0] = (uint32) (max[0] + 1); + granule.maxBand[1] = (uint32) (max[1] + 1); + granule.maxBand[2] = (uint32) (max[2] + 1); + granule.maxBandl = (uint32) (max[3] + 1); const int rmax = jmax (max[0], max[1], max[3]) + 1; - granule.maxb = rmax ? constants.shortLimit[sampleRate][rmax] - : constants.longLimit[sampleRate][max[3] + 1]; + granule.maxb = rmax ? (uint32) constants.shortLimit[sampleRate][rmax] + : (uint32) constants.longLimit[sampleRate][max[3] + 1]; } else { @@ -2782,10 +2783,10 @@ private: } } - zeromem (xrpnt, sizeof (float) * (&xr[32][0] - xrpnt)); + zeromem (xrpnt, sizeof (float) * (size_t) (&xr[32][0] - xrpnt)); - granule.maxBandl = max + 1; - granule.maxb = constants.longLimit[sampleRate][granule.maxBandl]; + granule.maxBandl = (uint32) (max + 1); + granule.maxb = (uint32) constants.longLimit[sampleRate][granule.maxBandl]; } while (part2remain > 16) @@ -2826,7 +2827,7 @@ private: ts += 2; } - const int bt = granule.blockType; + const uint32 bt = granule.blockType; if (bt == 2) { for (; sb < (int) granule.maxb; sb += 2, ts += 2, rawout1 += 36, rawout2 += 36) @@ -2947,7 +2948,7 @@ public: bitsPerSample = 32; usesFloatingPointData = true; sampleRate = stream.frame.getFrequency(); - numChannels = stream.frame.numChannels; + numChannels = (unsigned int) stream.frame.numChannels; lengthInSamples = findLength (streamPos); } } @@ -3001,17 +3002,17 @@ public: { for (int i = numDestChannels; --i >= 0;) if (destSamples[i] != nullptr) - zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (float) * numSamples); + zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (float) * (size_t) numSamples); return false; } const int numToCopy = jmin (decodedEnd - decodedStart, numSamples); float* const* const dst = reinterpret_cast (destSamples); - memcpy (dst[0] + startOffsetInDestBuffer, decoded0 + decodedStart, sizeof (float) * numToCopy); + memcpy (dst[0] + startOffsetInDestBuffer, decoded0 + decodedStart, sizeof (float) * (size_t) numToCopy); if (numDestChannels > 1 && dst[1] != nullptr) - memcpy (dst[1] + startOffsetInDestBuffer, (numChannels < 2 ? decoded0 : decoded1) + decodedStart, sizeof (float) * numToCopy); + memcpy (dst[1] + startOffsetInDestBuffer, (numChannels < 2 ? decoded0 : decoded1) + decodedStart, sizeof (float) * (size_t) numToCopy); startOffsetInDestBuffer += numToCopy; decodedStart += numToCopy; @@ -3064,7 +3065,7 @@ private: void skipID3() { const int64 originalPosition = stream.stream.getPosition(); - const uint32 firstWord = stream.stream.readInt(); + const uint32 firstWord = (uint32) stream.stream.readInt(); if ((firstWord & 0xffffff) == 0x334449) { @@ -3074,10 +3075,10 @@ private: && buffer[0] != 0xff && ((buffer[2] | buffer[3] | buffer[4] | buffer[5]) & 0x80) == 0) { - const int length = (((uint32) buffer[2]) << 21) - | (((uint32) buffer[3]) << 14) - | (((uint32) buffer[4]) << 7) - | ((uint32) buffer[5]); + const uint32 length = (((uint32) buffer[2]) << 21) + | (((uint32) buffer[3]) << 14) + | (((uint32) buffer[4]) << 7) + | ((uint32) buffer[5]); stream.stream.skipNextBytes (length); return; diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 1f85ff27d8..f127647adc 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -308,8 +308,8 @@ public: if (ogg_stream_flush (&os, &og) == 0) break; - output->write (og.header, og.header_len); - output->write (og.body, og.body_len); + output->write (og.header, (size_t) og.header_len); + output->write (og.body, (size_t) og.body_len); } ok = true; @@ -391,8 +391,8 @@ public: if (ogg_stream_pageout (&os, &og) == 0) break; - output->write (og.header, og.header_len); - output->write (og.body, og.body_len); + output->write (og.header, (size_t) og.header_len); + output->write (og.body, (size_t) og.body_len); if (ogg_page_eos (&og)) break; diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 21317b5cee..2586aa8511 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -70,6 +70,7 @@ const char* const WavAudioFormat::acidTempo = "acid tempo"; namespace WavFileHelpers { inline int chunkName (const char* const name) noexcept { return (int) ByteOrder::littleEndianInt (name); } + inline size_t roundUpSize (size_t sz) noexcept { return (sz + 3) & ~3u; } #if JUCE_MSVC #pragma pack (push, 1) @@ -108,8 +109,7 @@ namespace WavFileHelpers static MemoryBlock createFrom (const StringPairArray& values) { - const size_t sizeNeeded = sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8(); - MemoryBlock data ((sizeNeeded + 3) & ~3); + MemoryBlock data (roundUpSize (sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8())); data.fillWith (0); BWAVChunk* b = (BWAVChunk*) data.getData(); @@ -223,8 +223,7 @@ namespace WavFileHelpers if (numLoops > 0) { - const size_t sizeNeeded = sizeof (SMPLChunk) + (size_t) (numLoops - 1) * sizeof (SampleLoop); - data.setSize ((sizeNeeded + 3) & ~3, true); + data.setSize (roundUpSize (sizeof (SMPLChunk) + (size_t) (numLoops - 1) * sizeof (SampleLoop)), true); SMPLChunk* const s = static_cast (data.getData()); @@ -353,8 +352,7 @@ namespace WavFileHelpers if (numCues > 0) { - const size_t sizeNeeded = sizeof (CueChunk) + (size_t) (numCues - 1) * sizeof (Cue); - data.setSize ((sizeNeeded + 3) & ~3, true); + data.setSize (roundUpSize (sizeof (CueChunk) + (size_t) (numCues - 1) * sizeof (Cue)), true); CueChunk* const c = static_cast (data.getData()); @@ -417,7 +415,7 @@ namespace WavFileHelpers out.writeInt (chunkType); out.writeInt (chunkLength); out.writeInt (getValue (values, prefix, "Identifier")); - out.write (label.toUTF8(), labelLength); + out.write (label.toUTF8(), (size_t) labelLength); if ((out.getDataSize() & 1) != 0) out.writeByte (0); @@ -439,7 +437,7 @@ namespace WavFileHelpers out.writeShort ((short) getValue (values, prefix, "Language")); out.writeShort ((short) getValue (values, prefix, "Dialect")); out.writeShort ((short) getValue (values, prefix, "CodePage")); - out.write (text.toUTF8(), textLength); + out.write (text.toUTF8(), (size_t) textLength); if ((out.getDataSize() & 1) != 0) out.writeByte (0); @@ -471,10 +469,10 @@ namespace WavFileHelpers struct AcidChunk { /** Reads an acid RIFF chunk from a stream positioned just after the size byte. */ - AcidChunk (InputStream& input, int length) + AcidChunk (InputStream& input, size_t length) { zerostruct (*this); - input.read (this, jmin ((int) sizeof (*this), length)); + input.read (this, (int) jmin (sizeof (*this), length)); } void addToMetadata (StringPairArray& values) const @@ -876,6 +874,7 @@ public: //============================================================================== bool write (const int** data, int numSamples) override { + jassert (numSamples >= 0); jassert (data != nullptr && *data != nullptr); // the input must contain at least one channel! if (writeFailed) @@ -905,7 +904,7 @@ public: else { bytesWritten += bytes; - lengthInSamples += numSamples; + lengthInSamples += (uint64) numSamples; return true; } diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index 1c2f9bad6c..fe20524c50 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -89,7 +89,7 @@ bool BufferingAudioReader::readSamples (int** destSamples, int numDestChannels, } else { - if (timeoutMs >= 0 && Time::getMillisecondCounter() >= startTime + timeoutMs) + if (timeoutMs >= 0 && Time::getMillisecondCounter() >= startTime + (uint32) timeoutMs) { for (int j = 0; j < numDestChannels; ++j) if (float* dest = (float*) destSamples[j]) @@ -110,7 +110,7 @@ bool BufferingAudioReader::readSamples (int** destSamples, int numDestChannels, BufferingAudioReader::BufferedBlock::BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples) : range (pos, pos + numSamples), - buffer (reader.numChannels, numSamples) + buffer ((int) reader.numChannels, numSamples) { reader.read (&buffer, 0, numSamples, pos, true, true); } diff --git a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h index df2de70d61..2ec6388be2 100644 --- a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h @@ -95,7 +95,7 @@ protected: { typedef AudioData::Pointer SourceType; - SourceType (addBytesToPointer (sampleToPointer (startSampleInFile), (bitsPerSample / 8) * channel), (int) numChannels) + SourceType (addBytesToPointer (sampleToPointer (startSampleInFile), ((int) bitsPerSample / 8) * channel), (int) numChannels) .findMinAndMax ((size_t) numSamples, mn, mx); } diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index c5ebcf0055..b3cc31d1ec 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -153,7 +153,7 @@ void AudioProcessorPlayer::audioDeviceAboutToStart (AudioIODevice* const device) numOutputChans = numChansOut; messageCollector.reset (sampleRate); - channels.calloc (jmax (numChansIn, numChansOut) + 2); + channels.calloc ((size_t) jmax (numChansIn, numChansOut) + 2); if (processor != nullptr) { diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index a302d363d9..9ae4ee0132 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -678,12 +678,12 @@ var var::readFromStream (InputStream& input) case varMarker_Binary: { - MemoryBlock mb (numBytes - 1); + MemoryBlock mb ((size_t) numBytes - 1); if (numBytes > 1) { const int numRead = input.read (mb.getData(), numBytes - 1); - mb.setSize (numRead); + mb.setSize ((size_t) numRead); } return var (mb); diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 5c8a8352f6..f93f880a07 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -665,7 +665,7 @@ FileInputStream* File::createInputStream() const return nullptr; } -FileOutputStream* File::createOutputStream (const int bufferSize) const +FileOutputStream* File::createOutputStream (const size_t bufferSize) const { ScopedPointer out (new FileOutputStream (*this, bufferSize)); diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h index 0fcc8ec614..972070167e 100644 --- a/modules/juce_core/files/juce_File.h +++ b/modules/juce_core/files/juce_File.h @@ -580,7 +580,7 @@ public: end of the file), or nullptr if the file can't be opened for some reason @see createInputStream, appendData, appendText */ - FileOutputStream* createOutputStream (int bufferSize = 0x8000) const; + FileOutputStream* createOutputStream (size_t bufferSize = 0x8000) const; //============================================================================== /** Loads a file's contents into memory as a block of binary data. diff --git a/modules/juce_core/files/juce_FileOutputStream.cpp b/modules/juce_core/files/juce_FileOutputStream.cpp index fd14a4a9de..c4dd84aeb0 100644 --- a/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/modules/juce_core/files/juce_FileOutputStream.cpp @@ -29,14 +29,14 @@ int64 juce_fileSetPosition (void* handle, int64 pos); //============================================================================== -FileOutputStream::FileOutputStream (const File& f, const int bufferSize_) +FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse) : file (f), fileHandle (nullptr), status (Result::ok()), currentPosition (0), - bufferSize (bufferSize_), + bufferSize (bufferSizeToUse), bytesInBuffer (0), - buffer ((size_t) jmax (bufferSize_, 16)) + buffer (jmax (bufferSizeToUse, (size_t) 16)) { openHandle(); } diff --git a/modules/juce_core/files/juce_FileOutputStream.h b/modules/juce_core/files/juce_FileOutputStream.h index 9d001ff52e..f80705f23b 100644 --- a/modules/juce_core/files/juce_FileOutputStream.h +++ b/modules/juce_core/files/juce_FileOutputStream.h @@ -54,7 +54,7 @@ public: @see TemporaryFile */ FileOutputStream (const File& fileToWriteTo, - int bufferSizeToUse = 16384); + size_t bufferSizeToUse = 16384); /** Destructor. */ ~FileOutputStream(); diff --git a/modules/juce_core/memory/juce_MemoryBlock.cpp b/modules/juce_core/memory/juce_MemoryBlock.cpp index 29f9307981..2daa1dbfa7 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/modules/juce_core/memory/juce_MemoryBlock.cpp @@ -229,12 +229,12 @@ void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) noexc if (offset < 0) { d -= offset; - num -= offset; + num += (size_t) -offset; offset = 0; } - if (offset + num > size) - num = size - offset; + if ((size_t) offset + num > size) + num = size - (size_t) offset; if (num > 0) memcpy (data + offset, d, num); @@ -248,14 +248,13 @@ void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const noexcep { zeromem (d, (size_t) -offset); d -= offset; - - num += offset; + num -= (size_t) -offset; offset = 0; } - if (offset + num > size) + if ((size_t) offset + num > size) { - const size_t newNum = size - offset; + const size_t newNum = size - (size_t) offset; zeromem (d + newNum, num - newNum); num = newNum; } @@ -275,12 +274,12 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const int res = 0; size_t byte = bitRangeStart >> 3; - int offsetInByte = (int) bitRangeStart & 7; + size_t offsetInByte = bitRangeStart & 7; size_t bitsSoFar = 0; while (numBits > 0 && (size_t) byte < size) { - const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); + const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte; res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar); @@ -297,17 +296,17 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int bitsToSet) noexcept { size_t byte = bitRangeStart >> 3; - int offsetInByte = (int) bitRangeStart & 7; - unsigned int mask = ~((((unsigned int) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); + size_t offsetInByte = bitRangeStart & 7; + uint32 mask = ~((((uint32) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); while (numBits > 0 && (size_t) byte < size) { - const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); + const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); - const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int) 0xffffffff) >> offsetInByte) << offsetInByte); - const unsigned int tempBits = (unsigned int) bitsToSet << offsetInByte; + const uint32 tempMask = (mask << offsetInByte) | ~((((uint32) 0xffffffff) >> offsetInByte) << offsetInByte); + const uint32 tempBits = (uint32) bitsToSet << offsetInByte; - data[byte] = (char) ((data[byte] & tempMask) | tempBits); + data[byte] = (char) (((uint32) data[byte] & tempMask) | tempBits); ++byte; numBits -= bitsThisTime; @@ -336,22 +335,11 @@ void MemoryBlock::loadFromHexString (const String& hex) { const juce_wchar c = t.getAndAdvance(); - if (c >= '0' && c <= '9') - { - byte |= c - '0'; - break; - } - else if (c >= 'a' && c <= 'z') - { - byte |= c - ('a' - 10); - break; - } - else if (c >= 'A' && c <= 'Z') - { - byte |= c - ('A' - 10); - break; - } - else if (c == 0) + if (c >= '0' && c <= '9') { byte |= c - '0'; break; } + if (c >= 'a' && c <= 'z') { byte |= c - ('a' - 10); break; } + if (c >= 'A' && c <= 'Z') { byte |= c - ('A' - 10); break; } + + if (c == 0) { setSize (static_cast (dest - data)); return; @@ -372,7 +360,7 @@ String MemoryBlock::toBase64Encoding() const String destString ((unsigned int) size); // store the length, followed by a '.', and then the data. const int initialLen = destString.length(); - destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) (initialLen + 2 + numChars)); + destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) initialLen + 2 + numChars); String::CharPointerType d (destString.getCharPointer()); d += initialLen; diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index a1cf139fd2..ad77359f3e 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -1151,7 +1151,7 @@ struct HighResolutionTimer::Pimpl shouldStop = false; if (pthread_create (&thread, nullptr, timerThread, this) == 0) - setThreadToRealtime (thread, newPeriod); + setThreadToRealtime (thread, (uint64) newPeriod); else jassertfalse; } diff --git a/modules/juce_core/network/juce_IPAddress.cpp b/modules/juce_core/network/juce_IPAddress.cpp index 5fc1b00dc3..ced207d989 100644 --- a/modules/juce_core/network/juce_IPAddress.cpp +++ b/modules/juce_core/network/juce_IPAddress.cpp @@ -101,12 +101,12 @@ static void findIPAddresses (int sock, Array& result) { ifconf cfg; HeapBlock buffer; - size_t bufferSize = 1024; + int bufferSize = 1024; do { bufferSize *= 2; - buffer.calloc (bufferSize); + buffer.calloc ((size_t) bufferSize); cfg.ifc_len = bufferSize; cfg.ifc_buf = buffer; @@ -114,7 +114,7 @@ static void findIPAddresses (int sock, Array& result) if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL) return; - } while (bufferSize < cfg.ifc_len + 2 * (IFNAMSIZ + sizeof (struct sockaddr_in6))); + } while (bufferSize < cfg.ifc_len + 2 * (int) (IFNAMSIZ + sizeof (struct sockaddr_in6))); #if JUCE_MAC || JUCE_IOS while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in))) diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index 5a10938743..b965f3be8d 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -129,7 +129,7 @@ bool OutputStream::writeCompressedInt (int value) if (value < 0) data[0] |= 0x80; - return write (data, num + 1); + return write (data, (size_t) num + 1); } bool OutputStream::writeInt64 (int64 value) @@ -219,7 +219,7 @@ bool OutputStream::writeText (const String& text, const bool asUTF16, if (*t == '\n') { if (t > src) - if (! write (src, (int) (t - src))) + if (! write (src, (size_t) (t - src))) return false; if (! write ("\r\n", 2)) @@ -235,7 +235,7 @@ bool OutputStream::writeText (const String& text, const bool asUTF16, else if (*t == 0) { if (t > src) - if (! write (src, (int) (t - src))) + if (! write (src, (size_t) (t - src))) return false; break; @@ -263,7 +263,7 @@ int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWri if (num <= 0) break; - write (buffer, num); + write (buffer, (size_t) num); numBytesToWrite -= num; numWritten += num; diff --git a/modules/juce_core/xml/juce_XmlElement.cpp b/modules/juce_core/xml/juce_XmlElement.cpp index 7b34f59f3f..45ad447cfa 100644 --- a/modules/juce_core/xml/juce_XmlElement.cpp +++ b/modules/juce_core/xml/juce_XmlElement.cpp @@ -209,7 +209,7 @@ namespace XmlOutputFunctions } } - static void writeSpaces (OutputStream& out, const int numSpaces) + static void writeSpaces (OutputStream& out, const size_t numSpaces) { out.writeRepeatedByte (' ', numSpaces); } @@ -222,7 +222,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, using namespace XmlOutputFunctions; if (indentationLevel >= 0) - writeSpaces (outputStream, indentationLevel); + writeSpaces (outputStream, (size_t) indentationLevel); if (! isTextElement()) { @@ -230,7 +230,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, outputStream << tagName; { - const int attIndent = indentationLevel + tagName.length() + 1; + const size_t attIndent = (size_t) (indentationLevel + tagName.length() + 1); int lineLen = 0; for (const XmlAttributeNode* att = attributes; att != nullptr; att = att->nextListItem) @@ -279,7 +279,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, if (indentationLevel >= 0 && ! lastWasTextNode) { outputStream << newLine; - writeSpaces (outputStream, indentationLevel); + writeSpaces (outputStream, (size_t) indentationLevel); } outputStream.write ("imageData, imageData, lineStride * height); + memcpy (im->imageData, imageData, (size_t) (lineStride * height)); return im; } ImageType* createType() const override { return new NativeImageType(); } //============================================================================== - static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpace, - const bool mustOutliveSource) + static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpace, const bool mustOutliveSource) { const Image::BitmapData srcData (juceImage, Image::BitmapData::readOnly); CGDataProviderRef provider; @@ -87,11 +86,13 @@ public: } else { - provider = CGDataProviderCreateWithData (0, srcData.data, srcData.lineStride * srcData.height, 0); + provider = CGDataProviderCreateWithData (0, srcData.data, (size_t) (srcData.lineStride * srcData.height), 0); } - CGImageRef imageRef = CGImageCreate (srcData.width, srcData.height, - 8, srcData.pixelStride * 8, srcData.lineStride, + CGImageRef imageRef = CGImageCreate ((size_t) srcData.width, + (size_t) srcData.height, + 8, (size_t) srcData.pixelStride * 8, + (size_t) srcData.lineStride, colourSpace, getCGImageFlags (juceImage.getFormat()), provider, 0, true, kCGRenderingIntentDefault); @@ -209,7 +210,7 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList rects (numRects); int i = 0; @@ -639,10 +640,10 @@ CoreGraphicsContext::SavedState::SavedState() CoreGraphicsContext::SavedState::SavedState (const SavedState& other) : fillType (other.fillType), font (other.font), fontRef (other.fontRef), fontTransform (other.fontTransform), shading (0), - gradientLookupTable (other.numGradientLookupEntries), + gradientLookupTable ((size_t) other.numGradientLookupEntries), numGradientLookupEntries (other.numGradientLookupEntries) { - memcpy (gradientLookupTable, other.gradientLookupTable, sizeof (PixelARGB) * numGradientLookupEntries); + memcpy (gradientLookupTable, other.gradientLookupTable, sizeof (PixelARGB) * (size_t) numGradientLookupEntries); } CoreGraphicsContext::SavedState::~SavedState() diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index f793de1142..9de32e745b 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -293,7 +293,7 @@ namespace CoreTextTypeLayout #endif }; - CTParagraphStyleRef ctParagraphStyleRef = CTParagraphStyleCreate (settings, numElementsInArray (settings)); + CTParagraphStyleRef ctParagraphStyleRef = CTParagraphStyleCreate (settings, (size_t) numElementsInArray (settings)); CFAttributedStringSetAttribute (attribString, CFRangeMake (0, CFAttributedStringGetLength (attribString)), kCTParagraphStyleAttributeName, ctParagraphStyleRef); CFRelease (ctParagraphStyleRef); diff --git a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 43a6e72d53..96270c8024 100644 --- a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm @@ -27,6 +27,7 @@ //============================================================================== namespace MouseCursorHelpers { + NSImage* createNSImage (const Image&); NSImage* createNSImage (const Image& image) { JUCE_AUTORELEASEPOOL diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 0c8693f7e4..35f5e37953 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -829,14 +829,15 @@ void OpenGLContext::copyTexture (const Rectangle& targetClipArea, const OverlayShaderProgram& program = OverlayShaderProgram::select (*this); program.params.set ((float) contextWidth, (float) contextHeight, anchorPosAndTextureSize.toFloat(), flippedVertically); - extensions.glVertexAttribPointer (program.params.positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 4, vertices); - extensions.glEnableVertexAttribArray (program.params.positionAttribute.attributeID); + const GLuint index = (GLuint) program.params.positionAttribute.attributeID; + extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, vertices); + extensions.glEnableVertexAttribArray (index); JUCE_CHECK_OPENGL_ERROR glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); extensions.glUseProgram (0); - extensions.glDisableVertexAttribArray (program.params.positionAttribute.attributeID); + extensions.glDisableVertexAttribArray (index); } #if JUCE_USE_OPENGL_FIXED_FUNCTION else diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 7481a670a3..8a9ae9ba31 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -108,7 +108,7 @@ private: : area (et.getMaximumBounds().withSize (nextPowerOfTwo (et.getMaximumBounds().getWidth()), nextPowerOfTwo (et.getMaximumBounds().getHeight()))) { - data.calloc (area.getWidth() * area.getHeight()); + data.calloc ((size_t) (area.getWidth() * area.getHeight())); et.iterate (*this); } @@ -129,12 +129,12 @@ private: inline void handleEdgeTableLine (int x, int width, const int alphaLevel) const noexcept { - memset (currentLine + x, (uint8) alphaLevel, width); + memset (currentLine + x, (uint8) alphaLevel, (size_t) width); } inline void handleEdgeTableLineFull (int x, int width) const noexcept { - memset (currentLine + x, 255, width); + memset (currentLine + x, 255, (size_t) width); } HeapBlock data; @@ -215,16 +215,16 @@ public: void bindAttributes (OpenGLContext& context) { - context.extensions.glVertexAttribPointer (positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0); - context.extensions.glVertexAttribPointer (colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4); - context.extensions.glEnableVertexAttribArray (positionAttribute.attributeID); - context.extensions.glEnableVertexAttribArray (colourAttribute.attributeID); + context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0); + context.extensions.glVertexAttribPointer ((GLuint) colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4); + context.extensions.glEnableVertexAttribArray ((GLuint) positionAttribute.attributeID); + context.extensions.glEnableVertexAttribArray ((GLuint) colourAttribute.attributeID); } void unbindAttributes (OpenGLContext& context) { - context.extensions.glDisableVertexAttribArray (positionAttribute.attributeID); - context.extensions.glDisableVertexAttribArray (colourAttribute.attributeID); + context.extensions.glDisableVertexAttribArray ((GLuint) positionAttribute.attributeID); + context.extensions.glDisableVertexAttribArray ((GLuint) colourAttribute.attributeID); } OpenGLShaderProgram::Attribute positionAttribute, colourAttribute; @@ -813,7 +813,7 @@ struct StateHelpers if (currentActiveTexture != index) { currentActiveTexture = index; - context.extensions.glActiveTexture (GL_TEXTURE0 + index); + context.extensions.glActiveTexture ((GLenum) (GL_TEXTURE0 + index)); JUCE_CHECK_OPENGL_ERROR } } @@ -1029,7 +1029,7 @@ struct StateHelpers void draw() noexcept { - context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, numVertices * sizeof (VertexInfo), vertexData); + context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData); // NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in // their driver.. Can't find a workaround unfortunately. glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); @@ -1158,7 +1158,7 @@ public: { activeTextures.setTexturesEnabled (shaderQuadQueue, 3); activeTextures.setActiveTexture (1); - activeTextures.bindTexture (maskTextureID); + activeTextures.bindTexture ((GLuint) maskTextureID); activeTextures.setActiveTexture (0); textureCache.bindTextureForGradient (activeTextures, g); } @@ -1259,7 +1259,7 @@ public: if (maskArea != nullptr) { - activeTextures.setTwoTextureMode (shaderQuadQueue, image.textureID, maskTextureID); + activeTextures.setTwoTextureMode (shaderQuadQueue, image.textureID, (GLuint) maskTextureID); if (clampTiledImages) { diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 97f66de4b8..6089b768e5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -100,8 +100,8 @@ private: static void verticalRowFlip (PixelARGB* const data, const int w, const int h) { - HeapBlock tempRow (w); - const int rowSize = sizeof (PixelARGB) * w; + HeapBlock tempRow ((size_t) w); + const size_t rowSize = sizeof (PixelARGB) * (size_t) w; for (int y = 0; y < h / 2; ++y) { @@ -122,8 +122,8 @@ private: void write (const PixelARGB* const data) const noexcept { - HeapBlock invertedCopy (area.getWidth() * area.getHeight()); - const int rowSize = sizeof (PixelARGB) * area.getWidth(); + HeapBlock invertedCopy ((size_t) (area.getWidth() * area.getHeight())); + const size_t rowSize = sizeof (PixelARGB) * (size_t) area.getWidth(); for (int y = 0; y < area.getHeight(); ++y) memcpy (invertedCopy + area.getWidth() * y, @@ -142,7 +142,7 @@ private: struct DataReleaser : public Image::BitmapData::BitmapDataReleaser { DataReleaser (OpenGLFrameBuffer& fb, int x, int y, int w, int h) - : data (w * h), + : data ((size_t) (w * h)), writer (fb, x, y, w, h) {}