Browse Source

OSC: Fixed a number of integer conversion warnings.

tags/2021-05-28
Timur Doumler 10 years ago
parent
commit
19bf0ee663
3 changed files with 21 additions and 21 deletions
  1. +9
    -9
      modules/juce_osc/osc/juce_OSCReceiver.cpp
  2. +8
    -8
      modules/juce_osc/osc/juce_OSCSender.cpp
  3. +4
    -4
      modules/juce_osc/osc/juce_OSCTimeTag.cpp

+ 9
- 9
modules/juce_osc/osc/juce_OSCReceiver.cpp View File

@@ -55,7 +55,7 @@ namespace
size_t getDataSize() const noexcept { return input.getDataSize(); }
/** Returns the current position of the stream. */
int64 getPosition() { return input.getPosition(); }
uint64 getPosition() { return uint64 (input.getPosition()); }
/** Attempts to set the current position of the stream. Returns true if this was successful. */
bool setPosition (int64 pos) { return input.setPosition (pos); }
@@ -80,7 +80,7 @@ namespace
if (input.getNumBytesRemaining() < 8)
throw OSCFormatError ("OSC input stream exhausted while reading uint64");
return input.readInt64BigEndian();
return (uint64) input.readInt64BigEndian();
}
float readFloat32()
@@ -114,7 +114,7 @@ namespace
if (input.getNumBytesRemaining() < 4)
throw OSCFormatError ("OSC input stream exhausted while reading blob");
const size_t blobDataSize = static_cast<size_t> (input.readIntBigEndian());
const int64 blobDataSize = input.readIntBigEndian();
if (input.getNumBytesRemaining() < (blobDataSize + 3) % 4)
throw OSCFormatError ("OSC input stream exhausted before reaching end of blob");
@@ -132,7 +132,7 @@ namespace
if (input.getNumBytesRemaining() < 8)
throw OSCFormatError ("OSC input stream exhausted while reading time tag");
return OSCTimeTag (input.readInt64BigEndian());
return OSCTimeTag (uint64 (input.readInt64BigEndian()));
}
OSCAddress readAddress()
@@ -172,7 +172,7 @@ namespace
typeList.add (type);
}
size_t bytesRead = typeList.size() + 2;
size_t bytesRead = (size_t) typeList.size() + 2;
readPaddingZeros (bytesRead);
return typeList;
@@ -232,7 +232,7 @@ namespace
if (input.getNumBytesRemaining() < 4)
throw OSCFormatError("OSC input stream exhausted while reading bundle element size");
const int elementSize = readInt32();
const size_t elementSize = (size_t) readInt32();
if (elementSize < 4)
throw OSCFormatError("OSC input stream format error: invalid bundle element size");
@@ -243,7 +243,7 @@ namespace
//======================================================================
OSCBundle::Element readElementWithKnownSize (size_t elementSize)
{
if (input.getNumBytesRemaining() < elementSize)
if ((uint64) input.getNumBytesRemaining() < elementSize)
throw OSCFormatError ("OSC input stream exhausted while reading bundle element content");
const char firstContentChar = static_cast<const char*> (getData()) [getPosition()];
@@ -393,7 +393,7 @@ struct OSCReceiver::Pimpl : private Thread,
};
//==========================================================================
void handleBuffer (const char* data, int dataSize)
void handleBuffer (const char* data, size_t dataSize)
{
OSCInputStream inStream (data, dataSize);
@@ -439,7 +439,7 @@ private:
if (threadShouldExit())
return;
const int bytesRead = socket->read (buffer, (int) sizeof (buffer), false);
const size_t bytesRead = (size_t) socket->read (buffer, (int) sizeof (buffer), false);
if (bytesRead >= 4)
handleBuffer (buffer, bytesRead);


+ 8
- 8
modules/juce_osc/osc/juce_OSCSender.cpp View File

@@ -49,7 +49,7 @@ namespace
bool writeUint64 (uint64 value)
{
return output.writeInt64BigEndian (value);
return output.writeInt64BigEndian (int64 (value));
}
bool writeFloat32 (float value)
@@ -80,7 +80,7 @@ namespace
bool writeTimeTag (OSCTimeTag timeTag)
{
return output.writeInt64BigEndian (timeTag.getRawTimeTag());
return output.writeInt64BigEndian (int64 (timeTag.getRawTimeTag()));
}
bool writeAddress (const OSCAddress& address)
@@ -98,11 +98,11 @@ namespace
output.writeByte (',');
if (typeList.size() > 0)
output.write (typeList.begin(), typeList.size());
output.write (typeList.begin(), (size_t) typeList.size());
output.writeByte ('\0');
size_t bytesWritten = typeList.size() + 1;
size_t bytesWritten = (size_t) typeList.size() + 1;
size_t numPaddingZeros = ~bytesWritten & 0x03;
return output.writeRepeatedByte ('\0', numPaddingZeros);
@@ -163,7 +163,7 @@ namespace
//==========================================================================
bool writeBundleElement (const OSCBundle::Element& element)
{
const size_t startPos = (size_t) output.getPosition();
const int64 startPos = output.getPosition();
if (! writeInt32 (0)) // writing dummy value for element size
return false;
@@ -179,11 +179,11 @@ namespace
return false;
}
const size_t endPos = (size_t) output.getPosition();
const size_t elementSize = endPos - (startPos + 4);
const int64 endPos = output.getPosition();
const int64 elementSize = endPos - (startPos + 4);
return output.setPosition (startPos)
&& writeInt32 ((int) elementSize)
&& writeInt32 ((int32) elementSize)
&& output.setPosition (endPos);
}


+ 4
- 4
modules/juce_osc/osc/juce_OSCTimeTag.cpp View File

@@ -38,7 +38,7 @@ OSCTimeTag::OSCTimeTag (uint64 t) noexcept : rawTimeTag (t)
OSCTimeTag::OSCTimeTag (Time time) noexcept
{
const int64 milliseconds = time.toMilliseconds() + millisecondsBetweenOscAndJuceEpochs;
const uint64 milliseconds = (uint64) time.toMilliseconds() + millisecondsBetweenOscAndJuceEpochs;
// something went seriously wrong if the line above didn't render the time nonnegative!
jassert (milliseconds >= 0);
@@ -58,9 +58,9 @@ Time OSCTimeTag::toTime() const noexcept
const double fractionalPartInMillis = (double) fractionalPart / 4294967.296;
// now using signed integer, because this is allowed to become negative:
const int64 juceTimeInMillis = (seconds * 1000)
+ roundToInt(fractionalPartInMillis)
- (int64) millisecondsBetweenOscAndJuceEpochs;
const int64 juceTimeInMillis = int64 ((seconds * 1000)
+ (uint64) roundToInt(fractionalPartInMillis)
- millisecondsBetweenOscAndJuceEpochs);
return Time (juceTimeInMillis);
}


Loading…
Cancel
Save