mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 18:15:50 +00:00
Fix warnings
This commit is contained in:
@@ -673,12 +673,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);
|
||||
|
||||
@@ -687,7 +687,7 @@ FileInputStream* File::createInputStream() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileOutputStream* File::createOutputStream (const int bufferSize) const
|
||||
FileOutputStream* File::createOutputStream (const size_t bufferSize) const
|
||||
{
|
||||
ScopedPointer<FileOutputStream> out (new FileOutputStream (*this, bufferSize));
|
||||
|
||||
|
||||
@@ -585,7 +585,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.
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
int64 beast_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) bmax (bufferSize_, 16))
|
||||
buffer (bmax (bufferSizeToUse, (size_t) 16))
|
||||
{
|
||||
openHandle();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
@see TemporaryFile
|
||||
*/
|
||||
FileOutputStream (const File& fileToWriteTo,
|
||||
int bufferSizeToUse = 16384);
|
||||
size_t bufferSizeToUse = 16384);
|
||||
|
||||
/** Destructor. */
|
||||
~FileOutputStream();
|
||||
|
||||
@@ -224,12 +224,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);
|
||||
@@ -243,14 +243,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;
|
||||
}
|
||||
@@ -270,12 +269,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 = bmin ((int) numBits, 8 - offsetInByte);
|
||||
const size_t bitsThisTime = bmin (numBits, 8 - offsetInByte);
|
||||
const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte;
|
||||
|
||||
res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar);
|
||||
@@ -292,17 +291,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 = bmin ((int) numBits, 8 - offsetInByte);
|
||||
const size_t bitsThisTime = bmin (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;
|
||||
@@ -331,22 +330,11 @@ void MemoryBlock::loadFromHexString (const String& hex)
|
||||
{
|
||||
const beast_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 <size_t> (dest - data));
|
||||
return;
|
||||
@@ -367,7 +355,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;
|
||||
@@ -413,4 +401,4 @@ bool MemoryBlock::fromBase64Encoding (const String& s)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1327,7 +1327,7 @@ struct HighResolutionTimer::Pimpl : public Uncopyable
|
||||
shouldStop = false;
|
||||
|
||||
if (pthread_create (&thread, nullptr, timerThread, this) == 0)
|
||||
setThreadToRealtime (thread, newPeriod);
|
||||
setThreadToRealtime (thread, (uint64) newPeriod);
|
||||
else
|
||||
bassertfalse;
|
||||
}
|
||||
|
||||
@@ -96,12 +96,12 @@ static void findIPAddresses (int sock, Array<IPAddress>& result)
|
||||
{
|
||||
ifconf cfg;
|
||||
HeapBlock<char> 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;
|
||||
@@ -109,7 +109,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& 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 BEAST_MAC || BEAST_IOS
|
||||
while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in)))
|
||||
|
||||
@@ -142,7 +142,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)
|
||||
@@ -232,7 +232,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))
|
||||
@@ -248,7 +248,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;
|
||||
@@ -276,7 +276,7 @@ int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWri
|
||||
if (num <= 0)
|
||||
break;
|
||||
|
||||
write (buffer, num);
|
||||
write (buffer, (size_t) num);
|
||||
|
||||
numBytesToWrite -= num;
|
||||
numWritten += num;
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace XmlOutputFunctions
|
||||
}
|
||||
}
|
||||
|
||||
static void writeSpaces (OutputStream& out, const int numSpaces)
|
||||
static void writeSpaces (OutputStream& out, const size_t numSpaces)
|
||||
{
|
||||
out.writeRepeatedByte (' ', numSpaces);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
|
||||
using namespace XmlOutputFunctions;
|
||||
|
||||
if (indentationLevel >= 0)
|
||||
writeSpaces (outputStream, indentationLevel);
|
||||
writeSpaces (outputStream, (size_t) indentationLevel);
|
||||
|
||||
if (! isTextElement())
|
||||
{
|
||||
@@ -225,7 +225,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)
|
||||
@@ -274,7 +274,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
|
||||
if (indentationLevel >= 0 && ! lastWasTextNode)
|
||||
{
|
||||
outputStream << newLine;
|
||||
writeSpaces (outputStream, indentationLevel);
|
||||
writeSpaces (outputStream, (size_t) indentationLevel);
|
||||
}
|
||||
|
||||
outputStream.write ("</", 2);
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
{
|
||||
data += dataSize - stream.avail_in;
|
||||
dataSize = stream.avail_in;
|
||||
const ssize_t bytesDone = sizeof (buffer) - (ssize_t) stream.avail_out;
|
||||
const ssize_t bytesDone = (ssize_t) sizeof (buffer) - (ssize_t) stream.avail_out;
|
||||
return bytesDone <= 0 || out.write (buffer, (size_t) bytesDone);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user