1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-30 02:50:05 +00:00

Fixed some more warnings.

This commit is contained in:
jules 2012-09-24 15:45:25 +01:00
parent a180c6c358
commit 6b1654e1d2
47 changed files with 129 additions and 116 deletions

View file

@ -880,7 +880,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
unsigned int hash = 0;
if (resourceNameUTF8 != 0)
while (*resourceNameUTF8 != 0)
hash = 31 * hash + *resourceNameUTF8++;
hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
switch (hash)
{

View file

@ -343,7 +343,7 @@ namespace CodeHelpers
const char* t = s.toUTF8();
unsigned int hash = 0;
while (*t != 0)
hash = hashMultiplier * hash + *t++;
hash = hashMultiplier * hash + (unsigned int) *t++;
return hash;
}
@ -387,7 +387,7 @@ namespace CodeHelpers
out << indent << "unsigned int hash = 0;" << newLine
<< indent << "if (" << utf8PointerVariable << " != 0)" << newLine
<< indent << " while (*" << utf8PointerVariable << " != 0)" << newLine
<< indent << " hash = " << hashMultiplier << " * hash + *" << utf8PointerVariable << "++;" << newLine
<< indent << " hash = " << hashMultiplier << " * hash + (unsigned int) *" << utf8PointerVariable << "++;" << newLine
<< newLine
<< indent << "switch (hash)" << newLine
<< indent << "{" << newLine;

View file

@ -2147,7 +2147,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
unsigned int hash = 0;
if (resourceNameUTF8 != 0)
while (*resourceNameUTF8 != 0)
hash = 31 * hash + *resourceNameUTF8++;
hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
switch (hash)
{

View file

@ -152,7 +152,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);
}
}

View file

@ -105,7 +105,7 @@ void LiveAudioInputDisplayComp::audioDeviceIOCallback (const float** inputChanne
// 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);
}
//[/MiscUserDefs]

View file

@ -112,7 +112,7 @@ public:
// The send button has been pressed, so write out the contents of the
// text box to the socket or pipe, depending on which is active.
const String text (sendText.getText());
MemoryBlock messageData (text.toUTF8(), text.getNumBytesAsUTF8());
MemoryBlock messageData (text.toUTF8(), (size_t) text.getNumBytesAsUTF8());
for (int i = activeConnections.size(); --i >= 0;)
{

View file

@ -514,7 +514,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
unsigned int hash = 0;
if (resourceNameUTF8 != 0)
while (*resourceNameUTF8 != 0)
hash = 31 * hash + *resourceNameUTF8++;
hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
switch (hash)
{

View file

@ -370,7 +370,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)
const int maxPacketSize = 256;
int pos = 0, bytesLeft = (int) dataSize;
const int numPackets = (bytesLeft + maxPacketSize - 1) / maxPacketSize;
allocatedPackets.malloc ((size_t) (32 * numPackets + dataSize), 1);
allocatedPackets.malloc ((size_t) (32 * (size_t) numPackets + dataSize), 1);
packetToSend = allocatedPackets;
packetToSend->numPackets = (UInt32) numPackets;

View file

@ -37,11 +37,11 @@ namespace OggVorbisNamespace
#pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365)
#endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#include "oggvorbis/vorbisenc.h"
#include "oggvorbis/codec.h"
@ -149,7 +149,7 @@ public:
if (destSamples[i] != nullptr)
memcpy (destSamples[i] + startOffsetInDestBuffer,
reservoir.getSampleData (i, (int) (startSampleInFile - reservoirStart)),
sizeof (float) * numToUse);
sizeof (float) * (size_t) numToUse);
startSampleInFile += numToUse;
numSamples -= numToUse;
@ -188,7 +188,7 @@ public:
{
memcpy (reservoir.getSampleData (i, offset),
dataIn[i],
sizeof (float) * samps);
sizeof (float) * (size_t) samps);
}
numToRead -= samps;
@ -204,7 +204,7 @@ public:
{
for (int i = numDestChannels; --i >= 0;)
if (destSamples[i] != nullptr)
zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * numSamples);
zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * (size_t) numSamples);
}
return true;
@ -213,7 +213,7 @@ public:
//==============================================================================
static size_t oggReadCallback (void* ptr, size_t size, size_t nmemb, void* datasource)
{
return (size_t) (static_cast <InputStream*> (datasource)->read (ptr, (int) (size * nmemb)) / size);
return (size_t) (static_cast <InputStream*> (datasource)->read (ptr, (int) (size * nmemb))) / size;
}
static int oggSeekCallback (void* datasource, OggVorbisNamespace::ogg_int64_t offset, int whence)

View file

@ -199,7 +199,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples
}
const int bufferSize = (int) jmin (numSamples, (int64) 4096);
AudioSampleBuffer tempSampleBuffer (numChannels, bufferSize);
AudioSampleBuffer tempSampleBuffer ((int) numChannels, bufferSize);
float** const floatBuffer = tempSampleBuffer.getArrayOfChannels();
int* const* intBuffer = reinterpret_cast<int* const*> (floatBuffer);
@ -219,7 +219,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples
numSamples -= numToDo;
startSampleInFile += numToDo;
getStereoMinAndMax (floatBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax);
getStereoMinAndMax (floatBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax);
}
lowestLeft = lmin;
@ -242,7 +242,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples
numSamples -= numToDo;
startSampleInFile += numToDo;
getStereoMinAndMax (intBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax);
getStereoMinAndMax (intBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax);
}
lowestLeft = lmin / (float) std::numeric_limits<int>::max();

View file

@ -317,7 +317,7 @@ public:
if (isPositiveAndBelow (indexToInsertAt, numUsed))
{
insertPos += indexToInsertAt;
const int numberToMove = numUsed - indexToInsertAt;
const size_t numberToMove = (size_t) (numUsed - indexToInsertAt);
memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ObjectClass*));
}
else

View file

@ -46,8 +46,8 @@ inline void deleteAndZero (Type& pointer) { delete poi
This can be useful to avoid casting pointers to a char* and back when you want to move them by
a specific number of bytes,
*/
template <typename Type>
inline Type* addBytesToPointer (Type* pointer, int bytes) noexcept { return (Type*) (((char*) pointer) + bytes); }
template <typename Type, typename IntegerType>
inline Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept { return (Type*) (((char*) pointer) + bytes); }
/** A handy function which returns the difference between any two pointers, in bytes.
The address of the second pointer is subtracted from the first, and the difference in bytes is returned.

View file

@ -233,7 +233,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
buffer.calloc (size + 8);
_NSGetExecutablePath (buffer.getData(), &size);
return String::fromUTF8 (buffer, size);
return String::fromUTF8 (buffer, (int) size);
}
default:

View file

@ -160,8 +160,8 @@ public:
if (available > 0)
{
const ScopedLock sl (dataLock);
[data getBytes: dest length: available];
[data replaceBytesInRange: NSMakeRange (0, available) withBytes: nil length: 0];
[data getBytes: dest length: (NSUInteger) available];
[data replaceBytesInRange: NSMakeRange (0, (NSUInteger) available) withBytes: nil length: 0];
numDone += available;
numBytes -= available;

View file

@ -29,7 +29,7 @@ String String::fromCFString (CFStringRef cfString)
return String::empty;
CFRange range = { 0, CFStringGetLength (cfString) };
HeapBlock <UniChar> u (range.length + 1);
HeapBlock <UniChar> u ((size_t) range.length + 1);
CFStringGetCharacters (cfString, range, u);
u[range.length] = 0;
@ -39,7 +39,7 @@ String String::fromCFString (CFStringRef cfString)
CFStringRef String::toCFString() const
{
CharPointer_UTF16 utf16 (toUTF16());
return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), utf16.length());
return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), (CFIndex) utf16.length());
}
String String::convertToPrecomposedUnicode() const
@ -65,7 +65,7 @@ String String::convertToPrecomposedUnicode() const
if (CreateUnicodeToTextInfo (&map, &conversionInfo) == noErr)
{
const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer());
const size_t bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer());
HeapBlock <char> tempOut;
tempOut.calloc (bytesNeeded + 4);

View file

@ -68,10 +68,10 @@ SystemStats::CPUFlags::CPUFlags()
uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0;
SystemStatsHelpers::doCPUID (familyModel, extFeatures, dummy, features, 1);
hasMMX = (features & (1 << 23)) != 0;
hasSSE = (features & (1 << 25)) != 0;
hasSSE2 = (features & (1 << 26)) != 0;
has3DNow = (extFeatures & (1 << 31)) != 0;
hasMMX = (features & (1u << 23)) != 0;
hasSSE = (features & (1u << 25)) != 0;
hasSSE2 = (features & (1u << 26)) != 0;
has3DNow = (extFeatures & (1u << 31)) != 0;
#else
hasMMX = false;
hasSSE = false;
@ -235,10 +235,10 @@ public:
else
{
numerator = timebase.numer;
denominator = timebase.denom * (int64) 1000000;
denominator = timebase.denom * (uint64) 1000000;
}
highResTimerFrequency = (timebase.denom * (int64) 1000000000) / timebase.numer;
highResTimerFrequency = (timebase.denom * (uint64) 1000000000) / timebase.numer;
highResTimerToMillisecRatio = numerator / (double) denominator;
}
@ -255,7 +255,7 @@ public:
int64 highResTimerFrequency;
private:
int64 numerator, denominator;
uint64 numerator, denominator;
double highResTimerToMillisecRatio;
};

View file

@ -97,7 +97,7 @@ public:
while (bytesRead < maxBytesToRead)
{
const int bytesThisTime = maxBytesToRead - bytesRead;
const int numRead = (int) ::read (pipeIn, destBuffer, bytesThisTime);
const int numRead = (int) ::read (pipeIn, destBuffer, (size_t) bytesThisTime);
if (numRead <= 0)
{
@ -140,7 +140,7 @@ public:
while (bytesWritten < numBytesToWrite && ! hasExpired (timeoutEnd))
{
const int bytesThisTime = numBytesToWrite - bytesWritten;
const int numWritten = (int) ::write (pipeOut, sourceBuffer, bytesThisTime);
const int numWritten = (int) ::write (pipeOut, sourceBuffer, (size_t) bytesThisTime);
if (numWritten <= 0)
{
@ -172,7 +172,7 @@ private:
static uint32 getTimeoutEnd (const int timeOutMilliseconds)
{
return timeOutMilliseconds >= 0 ? Time::getMillisecondCounter() + timeOutMilliseconds : 0;
return timeOutMilliseconds >= 0 ? Time::getMillisecondCounter() + (uint32) timeOutMilliseconds : 0;
}
static bool hasExpired (const uint32 timeoutEnd)

View file

@ -205,7 +205,7 @@ File File::getCurrentWorkingDirectory()
char localBuffer [1024];
char* cwd = getcwd (localBuffer, sizeof (localBuffer) - 1);
int bufferSize = 4096;
size_t bufferSize = 4096;
while (cwd == nullptr && errno == ERANGE)
{
@ -500,7 +500,7 @@ int FileOutputStream::writeInternal (const void* const data, const int numBytes)
if (fileHandle != 0)
{
result = ::write (getFD (fileHandle), data, numBytes);
result = ::write (getFD (fileHandle), data, (size_t) numBytes);
if (result == -1)
status = getResultForErrno();
@ -1046,7 +1046,7 @@ public:
readHandle = fdopen (pipeHandle, "r");
if (readHandle != 0)
return fread (dest, 1, numBytes, readHandle);
return (int) fread (dest, 1, (size_t) numBytes, readHandle);
return 0;
}

View file

@ -97,7 +97,7 @@ namespace SocketHelpers
#if JUCE_WINDOWS
bytesThisTime = recv (handle, static_cast<char*> (destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0);
#else
while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), maxBytesToRead - bytesRead)) < 0
while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), (size_t) (maxBytesToRead - bytesRead))) < 0
&& errno == EINTR
&& connected)
{
@ -230,7 +230,7 @@ namespace SocketHelpers
}
setSocketBlockingState (handle, false);
const int result = ::connect (handle, info->ai_addr, (int) info->ai_addrlen);
const int result = ::connect (handle, info->ai_addr, (socklen_t) info->ai_addrlen);
freeaddrinfo (info);
if (result < 0)
@ -301,7 +301,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite)
#else
int result;
while ((result = (int) ::write (handle, sourceBuffer, numBytesToWrite)) < 0
while ((result = (int) ::write (handle, sourceBuffer, (size_t) numBytesToWrite)) < 0
&& errno == EINTR)
{
}
@ -564,7 +564,7 @@ int DatagramSocket::write (const void* sourceBuffer, const int numBytesToWrite)
jassert (serverAddress != nullptr && connected);
return connected ? (int) sendto (handle, (const char*) sourceBuffer,
numBytesToWrite, 0,
(size_t) numBytesToWrite, 0,
static_cast <const struct addrinfo*> (serverAddress)->ai_addr,
static_cast <const struct addrinfo*> (serverAddress)->ai_addrlen)
: -1;

View file

@ -69,7 +69,7 @@ int MemoryInputStream::read (void* const buffer, const int howMany)
return 0;
memcpy (buffer, addBytesToPointer (data, position), (size_t) num);
position += num;
position += (unsigned int) num;
return num;
}

View file

@ -70,10 +70,11 @@ void MemoryOutputStream::reset() noexcept
void MemoryOutputStream::prepareToWrite (int numBytes)
{
const size_t storageNeeded = position + numBytes;
jassert (numBytes >= 0);
size_t storageNeeded = position + (size_t) numBytes;
if (storageNeeded >= data.getSize())
data.ensureSize ((storageNeeded + jmin ((int) (storageNeeded / 2), 1024 * 1024) + 32) & ~31);
data.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u);
}
bool MemoryOutputStream::write (const void* const buffer, int howMany)
@ -84,7 +85,7 @@ bool MemoryOutputStream::write (const void* const buffer, int howMany)
{
prepareToWrite (howMany);
memcpy (static_cast<char*> (data.getData()) + position, buffer, (size_t) howMany);
position += howMany;
position += (size_t) howMany;
size = jmax (size, position);
}
@ -97,7 +98,7 @@ void MemoryOutputStream::writeRepeatedByte (uint8 byte, int howMany)
{
prepareToWrite (howMany);
memset (static_cast<char*> (data.getData()) + position, byte, (size_t) howMany);
position += howMany;
position += (size_t) howMany;
size = jmax (size, position);
}
}

View file

@ -107,7 +107,7 @@ bool CharacterFunctions::isLetterOrDigit (const juce_wchar character) noexcept
int CharacterFunctions::getHexDigitValue (const juce_wchar digit) noexcept
{
unsigned int d = digit - '0';
unsigned int d = (unsigned int) digit - '0';
if (d < (unsigned int) 10)
return (int) d;

View file

@ -343,7 +343,7 @@ public:
dest.writeNull();
return (int) (getAddressDifference (dest.getAddress(), startAddress) + sizeof (typename DestCharPointerType::CharType));
return (int) ((size_t) getAddressDifference (dest.getAddress(), startAddress) + sizeof (typename DestCharPointerType::CharType));
}
/** Copies characters from one string to another, up to a null terminator

View file

@ -133,7 +133,7 @@ public:
if (start.getAddress() == nullptr || start.isEmpty())
return getEmpty();
const size_t numBytes = end.getAddress() - start.getAddress();
const size_t numBytes = (size_t) (end.getAddress() - start.getAddress());
const CharPointerType dest (createUninitialisedBytes (numBytes + 1));
memcpy (dest.getAddress(), start, numBytes);
dest.getAddress()[numBytes] = 0;
@ -683,7 +683,7 @@ String& String::operator+= (const int number)
{
const size_t byteOffsetOfNull = getByteOffsetOfEnd();
const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull
+ sizeof (CharPointerType::CharType) * numExtraChars;
+ sizeof (CharPointerType::CharType) * (size_t) numExtraChars;
text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded);
@ -1051,7 +1051,7 @@ String String::repeatedString (const String& stringToRepeat, int numberOfTimesTo
if (numberOfTimesToRepeat <= 0)
return empty;
String result (PreallocationBytes (stringToRepeat.getByteOffsetOfEnd() * numberOfTimesToRepeat));
String result (PreallocationBytes (stringToRepeat.getByteOffsetOfEnd() * (size_t) numberOfTimesToRepeat));
CharPointerType n (result.text);
while (--numberOfTimesToRepeat >= 0)
@ -1077,7 +1077,7 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con
return *this;
const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress());
String result (PreallocationBytes (currentByteSize + extraChars * CharPointerType::getBytesRequiredFor (padCharacter)));
String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter)));
CharPointerType n (result.text);
while (--extraChars >= 0)
@ -1104,7 +1104,7 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co
return *this;
const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress());
String result (PreallocationBytes (currentByteSize + extraChars * CharPointerType::getBytesRequiredFor (padCharacter)));
String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter)));
CharPointerType n (result.text);
n.writeAll (text);
@ -1985,7 +1985,7 @@ struct StringEncodingConverter
CharPointerType_Src text (source.getCharPointer());
const size_t extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text);
const size_t endOffset = (text.sizeInBytes() + 3) & ~3; // the new string must be word-aligned or many Windows
const size_t endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows
// functions will fail to read it correctly!
source.preallocateBytes (endOffset + extraBytesNeeded);
text = source.getCharPointer();
@ -1994,8 +1994,8 @@ struct StringEncodingConverter
const CharPointerType_Dest extraSpace (static_cast <DestChar*> (newSpace));
#if JUCE_DEBUG // (This just avoids spurious warnings from valgrind about the uninitialised bytes at the end of the buffer..)
const int bytesToClear = jmin ((int) extraBytesNeeded, 4);
zeromem (addBytesToPointer (newSpace, (int) (extraBytesNeeded - bytesToClear)), (size_t) bytesToClear);
const size_t bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4);
zeromem (addBytesToPointer (newSpace, extraBytesNeeded - bytesToClear), bytesToClear);
#endif
CharPointerType_Dest (extraSpace).writeAll (text);
@ -2113,7 +2113,7 @@ public:
CharPointerType (buffer).writeAll (s.toUTF8());
test.expectEquals (String (CharPointerType (buffer)), s);
test.expect (CharPointerType::isValidString (buffer, strlen ((const char*) buffer)));
test.expect (CharPointerType::isValidString (buffer, (int) strlen ((const char*) buffer)));
}
};

View file

@ -328,7 +328,7 @@ String StringArray::joinIntoString (const String& separator, int start, int numb
return strings.getReference (start);
const size_t separatorBytes = separator.getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType);
size_t bytesNeeded = separatorBytes * (last - start - 1);
size_t bytesNeeded = separatorBytes * (size_t) (last - start - 1);
for (int i = start; i < last; ++i)
bytesNeeded += strings.getReference(i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType);

View file

@ -42,7 +42,7 @@ struct TextDiffHelpers
static void addInsertion (TextDiff& td, const String::CharPointerType& text, int index, int length)
{
TextDiff::Change c;
c.insertedText = String (text, length);
c.insertedText = String (text, (size_t) length);
c.start = index;
c.length = length;
td.changes.add (c);
@ -84,7 +84,7 @@ struct TextDiffHelpers
{
jassert (indexA >= 0 && indexA <= a.length);
jassert (indexB >= 0 && indexB <= b.length);
jassert (String (a.text + indexA, len) == String (b.text + indexB, len));
jassert (String (a.text + indexA, (size_t) len) == String (b.text + indexB, (size_t) len));
if (indexA > 0 && indexB > 0)
diffSkippingCommonStart (td, StringRegion (a.text, a.start, indexA),
@ -112,7 +112,7 @@ struct TextDiffHelpers
return 0;
HeapBlock<int> lines;
lines.calloc (lenB * 2 + 2);
lines.calloc (2 + 2 * (size_t) lenB);
int* l0 = lines;
int* l1 = l0 + lenB + 1;

View file

@ -28,7 +28,7 @@ ChildProcess::~ChildProcess() {}
bool ChildProcess::waitForProcessToFinish (const int timeoutMs) const
{
const int64 timeoutTime = Time::getMillisecondCounter() + timeoutMs;
const uint32 timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs;
do
{

View file

@ -156,7 +156,7 @@ bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const
// Doh! So how exactly do you expect this thread to wait for itself to stop??
jassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0);
const uint32 timeoutEnd = Time::getMillisecondCounter() + timeOutMilliseconds;
const uint32 timeoutEnd = Time::getMillisecondCounter() + (uint32) timeOutMilliseconds;
while (isThreadRunning())
{

View file

@ -170,7 +170,7 @@ bool ThreadPool::waitForJobToFinish (const ThreadPoolJob* const job,
while (contains (job))
{
if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs)
if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + (uint32) timeOutMs)
return false;
jobFinishedSignal.wait (2);
@ -260,7 +260,7 @@ bool ThreadPool::removeAllJobs (const bool interruptRunningJobs, const int timeO
if (jobsToWaitFor.size() == 0)
break;
if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs)
if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + (uint32) timeOutMs)
return false;
jobFinishedSignal.wait (20);

View file

@ -46,7 +46,7 @@ public:
zlibNamespace::deflateEnd (&stream);
}
bool write (const uint8* data, int dataSize, OutputStream& out)
bool write (const uint8* data, unsigned int dataSize, OutputStream& out)
{
// When you call flush() on a gzip stream, the stream is closed, and you can
// no longer continue to write data to it!
@ -62,7 +62,7 @@ public:
void finish (OutputStream& out)
{
const uint8* data = nullptr;
int dataSize = 0;
unsigned int dataSize = 0;
while (! finished)
doNextBlock (data, dataSize, out, Z_FINISH);
@ -76,7 +76,7 @@ private:
bool isFirstDeflate, streamIsValid, finished;
zlibNamespace::Bytef buffer[32768];
bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& out, const int flushMode)
bool doNextBlock (const uint8*& data, unsigned int& dataSize, OutputStream& out, const int flushMode)
{
using namespace zlibNamespace;
if (streamIsValid)
@ -98,7 +98,7 @@ private:
case Z_OK:
{
data += dataSize - stream.avail_in;
dataSize = (int) stream.avail_in;
dataSize = stream.avail_in;
const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out;
return bytesDone <= 0 || out.write (buffer, bytesDone);
}
@ -140,7 +140,8 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany)
{
jassert (destBuffer != nullptr && howMany >= 0);
return helper->write (static_cast <const uint8*> (destBuffer), howMany, *destStream);
return helper->write (static_cast <const uint8*> (destBuffer),
(unsigned int) howMany, *destStream);
}
int64 GZIPCompressorOutputStream::getPosition()
@ -176,7 +177,7 @@ public:
for (int j = rng.nextInt (100); --j >= 0;)
{
MemoryBlock data (rng.nextInt (2000) + 1);
MemoryBlock data ((unsigned int) (rng.nextInt (2000) + 1));
for (int k = (int) data.getSize(); --k >= 0;)
data[k] = (char) rng.nextInt (255);

View file

@ -109,7 +109,7 @@ public:
dataSize = size;
}
int doNextBlock (uint8* const dest, const int destSize)
int doNextBlock (uint8* const dest, const unsigned int destSize)
{
using namespace zlibNamespace;
if (streamIsValid && data != nullptr && ! finished)
@ -209,7 +209,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany)
while (! helper->error)
{
const int n = helper->doNextBlock (d, howMany);
const int n = helper->doNextBlock (d, (unsigned int) howMany);
currentPos += n;
if (n == 0)

View file

@ -89,7 +89,7 @@ public:
}
int replaceIndex = 0;
size_t bestLastUsageCount = std::numeric_limits<int>::max();
size_t bestLastUsageCount = std::numeric_limits<size_t>::max();
for (int i = faces.size(); --i >= 0;)
{

View file

@ -391,7 +391,7 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
jpeg_start_compress (&jpegCompStruct, TRUE);
const int strideBytes = (int) (jpegCompStruct.image_width * jpegCompStruct.input_components);
const int strideBytes = (int) (jpegCompStruct.image_width * (unsigned int) jpegCompStruct.input_components);
JSAMPARRAY buffer = (*jpegCompStruct.mem->alloc_sarray) ((j_common_ptr) &jpegCompStruct,
JPOOL_IMAGE, (JDIMENSION) strideBytes, 1);

View file

@ -55,6 +55,11 @@ namespace pnglibNamespace
using std::free;
#endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#endif
using std::abs;
#define PNG_INTERNAL
#define NO_DUMMY_DECL
@ -79,6 +84,10 @@ namespace pnglibNamespace
#include "pnglib/pngwrite.c"
#include "pnglib/pngwtran.c"
#include "pnglib/pngwutil.c"
#if JUCE_CLANG
#pragma clang diagnostic pop
#endif
#else
extern "C"
{

View file

@ -51,7 +51,7 @@ Image ImageType::convert (const Image& source) const
jassert (src.pixelStride == dest.pixelStride && src.pixelFormat == dest.pixelFormat);
for (int y = 0; y < dest.height; ++y)
memcpy (dest.getLinePointer (y), src.getLinePointer (y), dest.lineStride);
memcpy (dest.getLinePointer (y), src.getLinePointer (y), (size_t) dest.lineStride);
return newImage;
}

View file

@ -101,7 +101,7 @@ public:
uint32 lastUseTime;
};
int cacheTimeout;
unsigned int cacheTimeout;
juce_DeclareSingleton_SingleThreaded_Minimal (ImageCache::Pimpl);
@ -159,5 +159,6 @@ Image ImageCache::getFromMemory (const void* imageData, const int dataSize)
void ImageCache::setCacheTimeout (const int millisecs)
{
Pimpl::getInstance()->cacheTimeout = millisecs;
jassert (millisecs >= 0);
Pimpl::getInstance()->cacheTimeout = (unsigned int) millisecs;
}

View file

@ -130,7 +130,7 @@ namespace CoreTextTypeLayout
{
if (advances == nullptr)
{
local.malloc (numGlyphs);
local.malloc ((size_t) numGlyphs);
CTRunGetAdvances (run, CFRangeMake (0, 0), local);
advances = local;
}
@ -142,7 +142,7 @@ namespace CoreTextTypeLayout
struct Glyphs
{
Glyphs (CTRunRef run, const int numGlyphs)
Glyphs (CTRunRef run, const size_t numGlyphs)
: glyphs (CTRunGetGlyphsPtr (run))
{
if (glyphs == nullptr)
@ -159,7 +159,7 @@ namespace CoreTextTypeLayout
struct Positions
{
Positions (CTRunRef run, const int numGlyphs)
Positions (CTRunRef run, const size_t numGlyphs)
: points (CTRunGetPositionsPtr (run))
{
if (points == nullptr)
@ -383,9 +383,9 @@ namespace CoreTextTypeLayout
glyphRun->colour = Colour::fromFloatRGBA (components[0], components[1], components[2], components[3]);
}
const CoreTextTypeLayout::Glyphs glyphs (run, numGlyphs);
const CoreTextTypeLayout::Glyphs glyphs (run, (size_t) numGlyphs);
const CoreTextTypeLayout::Advances advances (run, numGlyphs);
const CoreTextTypeLayout::Positions positions (run, numGlyphs);
const CoreTextTypeLayout::Positions positions (run, (size_t) numGlyphs);
for (CFIndex k = 0; k < numGlyphs; ++k)
glyphRun->glyphs.add (TextLayout::Glyph (glyphs.glyphs[k], Point<float> (positions.points[k].x,
@ -511,7 +511,7 @@ public:
CFIndex length = CTRunGetGlyphCount (run);
const CoreTextTypeLayout::Advances advances (run, length);
const CoreTextTypeLayout::Glyphs glyphs (run, length);
const CoreTextTypeLayout::Glyphs glyphs (run, (size_t) length);
for (int j = 0; j < length; ++j)
{

View file

@ -211,7 +211,7 @@ LookAndFeel::LookAndFeel()
};
for (int i = 0; i < numElementsInArray (standardColours); i += 2)
setColour (standardColours [i], Colour ((uint32) standardColours [i + 1]));
setColour ((int) standardColours [i], Colour ((uint32) standardColours [i + 1]));
juce_getTypefaceForFont = LookAndFeelHelpers::getTypefaceForFontFromLookAndFeel;
}

View file

@ -233,7 +233,7 @@ public:
[item setState: iter.isTicked ? NSOnState : NSOffState];
[item setTarget: (id) callback];
NSMutableArray* info = [NSMutableArray arrayWithObject: [NSNumber numberWithUnsignedLongLong: (pointer_sized_int) (void*) iter.commandManager]];
NSMutableArray* info = [NSMutableArray arrayWithObject: [NSNumber numberWithUnsignedLongLong: (pointer_sized_uint) (void*) iter.commandManager]];
[info addObject: [NSNumber numberWithInt: topLevelIndex]];
[item setRepresentedObject: info];

View file

@ -1506,7 +1506,7 @@ private:
static NSRange markedRange (id self, SEL)
{
NSViewComponentPeer* const owner = getOwner (self);
return owner->stringBeingComposed.isNotEmpty() ? NSMakeRange (0, owner->stringBeingComposed.length())
return owner->stringBeingComposed.isNotEmpty() ? NSMakeRange (0, (NSUInteger) owner->stringBeingComposed.length())
: NSMakeRange (NSNotFound, 0);
}
@ -1519,7 +1519,8 @@ private:
const Range<int> highlight (target->getHighlightedRegion());
if (! highlight.isEmpty())
return NSMakeRange (highlight.getStart(), highlight.getLength());
return NSMakeRange ((NSUInteger) highlight.getStart(),
(NSUInteger) highlight.getLength());
}
}

View file

@ -183,7 +183,7 @@ void TooltipWindow::timerCallback()
// appear after a timeout..
if (newTip.isNotEmpty()
&& newTip != tipShowing
&& now > lastCompChangeTime + millisecondsBeforeTipAppears)
&& now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears)
{
showFor (newTip);
}

View file

@ -60,7 +60,7 @@ CodeEditorComponent::ColourScheme CPlusPlusCodeTokeniser::getDefaultColourScheme
CodeEditorComponent::ColourScheme cs;
for (int i = 0; i < sizeof (types) / sizeof (types[0]); ++i) // (NB: numElementsInArray doesn't work here in GCC4.2)
for (unsigned int i = 0; i < sizeof (types) / sizeof (types[0]); ++i) // (NB: numElementsInArray doesn't work here in GCC4.2)
cs.set (types[i].name, Colour (types[i].colour));
return cs;

View file

@ -69,7 +69,7 @@ void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving,
deleteAfterUse = deleteSelfAfterUse;
expiryTime = numMillisecondsBeforeRemoving > 0
? (Time::getMillisecondCounter() + numMillisecondsBeforeRemoving) : 0;
? (Time::getMillisecondCounter() + (uint32) numMillisecondsBeforeRemoving) : 0;
mouseClickCounter = Desktop::getInstance().getMouseButtonClickCounter();

View file

@ -100,8 +100,8 @@ class OpenGLContext::NativeContext
{
public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixelFormat,
void* contextToShareWith)
const OpenGLPixelFormat& pixFormat,
void* contextToShare)
{
NSOpenGLPixelFormatAttribute attribs[] =
{
@ -109,14 +109,14 @@ public:
NSOpenGLPFAMPSafe,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFANoRecovery,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.redBits + pixelFormat.greenBits + pixelFormat.blueBits),
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits,
NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.accumulationBufferRedBits + pixelFormat.accumulationBufferGreenBits
+ pixelFormat.accumulationBufferBlueBits + pixelFormat.accumulationBufferAlphaBits),
pixelFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0,
(NSOpenGLPixelFormatAttribute) pixelFormat.multisamplingLevel,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixFormat.redBits + pixFormat.greenBits + pixFormat.blueBits),
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixFormat.alphaBits,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixFormat.depthBufferBits,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixFormat.stencilBufferBits,
NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixFormat.accumulationBufferRedBits + pixFormat.accumulationBufferGreenBits
+ pixFormat.accumulationBufferBlueBits + pixFormat.accumulationBufferAlphaBits),
pixFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0,
(NSOpenGLPixelFormatAttribute) pixFormat.multisamplingLevel,
0
};
@ -133,7 +133,7 @@ public:
object: view];
renderContext = [[[NSOpenGLContext alloc] initWithFormat: format
shareContext: (NSOpenGLContext*) contextToShareWith] autorelease];
shareContext: (NSOpenGLContext*) contextToShare] autorelease];
setSwapInterval (1);

View file

@ -150,7 +150,7 @@ class OpenGLFrameBuffer::SavedState
public:
SavedState (OpenGLFrameBuffer& buffer, const int w, const int h)
: width (w), height (h),
data (w * h)
data ((size_t) (w * h))
{
buffer.readPixels (data, Rectangle<int> (w, h));
}

View file

@ -62,9 +62,9 @@ bool OpenGLShaderProgram::addShader (const char* const code, GLenum type)
if (status == GL_FALSE)
{
GLchar infoLog [16384];
GLsizei infologLength = 0;
context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infologLength, infoLog);
errorLog = String (infoLog, infologLength);
GLsizei infoLogLength = 0;
context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infoLogLength, infoLog);
errorLog = String (infoLog, (size_t) infoLogLength);
#if JUCE_DEBUG
DBG (errorLog);
@ -90,9 +90,9 @@ bool OpenGLShaderProgram::link() noexcept
if (status == GL_FALSE)
{
GLchar infoLog [16384];
GLsizei infologLength = 0;
context.extensions.glGetProgramInfoLog (programID, sizeof (infoLog), &infologLength, infoLog);
errorLog = String (infoLog, infologLength);
GLsizei infoLogLength = 0;
context.extensions.glGetProgramInfoLog (programID, sizeof (infoLog), &infoLogLength, infoLog);
errorLog = String (infoLog, (size_t) infoLogLength);
#if JUCE_DEBUG
DBG (errorLog);

View file

@ -79,7 +79,7 @@ struct Flipper
static void flip (HeapBlock<PixelARGB>& dataCopy, const uint8* srcData, const int lineStride,
const int w, const int h, const int textureW, const int textureH)
{
dataCopy.malloc (textureW * textureH);
dataCopy.malloc ((size_t) (textureW * textureH));
for (int y = 0; y < h; ++y)
{