mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 14:59:54 +00:00
Fix compiler warnings in unit tests. (#488)
This commit is contained in:
@@ -67,8 +67,8 @@ void TestHmacSha256(void)
|
||||
|
||||
for (int i = 0; tests[i].key != NULL; i++)
|
||||
{
|
||||
otCryptoHmacSha256Start(tests[i].key, strlen(tests[i].key));
|
||||
otCryptoHmacSha256Update(tests[i].data, strlen(tests[i].data));
|
||||
otCryptoHmacSha256Start(tests[i].key, static_cast<uint16_t>(strlen(tests[i].key)));
|
||||
otCryptoHmacSha256Update(tests[i].data, static_cast<uint16_t>(strlen(tests[i].data)));
|
||||
otCryptoHmacSha256Finish(hash);
|
||||
|
||||
VerifyOrQuit(memcmp(hash, tests[i].hash, sizeof(tests[i].hash)) == 0,
|
||||
|
||||
@@ -83,7 +83,7 @@ void TestLowpanIphc(void)
|
||||
Message *message = NULL;
|
||||
|
||||
uint8_t result[1500];
|
||||
unsigned resultLength = 0;
|
||||
uint16_t resultLength = 0;
|
||||
|
||||
Mac::Address macSource;
|
||||
Mac::Address macDest;
|
||||
@@ -112,7 +112,7 @@ void TestLowpanIphc(void)
|
||||
|
||||
Mac::Frame frame;
|
||||
frame.mPsdu = iphcVector.data();
|
||||
frame.mLength = iphcVector.size();
|
||||
frame.mLength = static_cast<uint8_t>(iphcVector.size());
|
||||
frame.GetSrcAddr(macSource);
|
||||
frame.GetDstAddr(macDest);
|
||||
|
||||
@@ -126,7 +126,7 @@ void TestLowpanIphc(void)
|
||||
frame.GetPayloadLength(), 0);
|
||||
|
||||
uint16_t ip6PayloadLength = frame.GetPayloadLength() -
|
||||
decompressedBytes;
|
||||
static_cast<uint16_t>(decompressedBytes);
|
||||
SuccessOrQuit(message->Append(frame.GetPayload() + decompressedBytes,
|
||||
ip6PayloadLength),
|
||||
"6lo: Message::Append failed");
|
||||
@@ -150,7 +150,7 @@ void TestLowpanIphc(void)
|
||||
printf("Compressed OpenThread:\n");
|
||||
otTestPrintHex(result, compressBytes);
|
||||
|
||||
VerifyOrQuit(memcmp(frame.GetPayload(), result, compressBytes) == 0,
|
||||
VerifyOrQuit(memcmp(frame.GetPayload(), result, static_cast<size_t>(compressBytes)) == 0,
|
||||
"6lo: Lowpan::Compress failed");
|
||||
|
||||
SuccessOrQuit(Message::Free(*message), "6lo: Message:Free failed");
|
||||
|
||||
@@ -36,7 +36,7 @@ extern"C" void otSignalTaskletPending(void)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C" void otPlatDiagAlarmFired()
|
||||
extern "C" void otPlatDiagAlarmFired(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void TestMessage(void)
|
||||
|
||||
for (unsigned i = 0; i < sizeof(writeBuffer); i++)
|
||||
{
|
||||
writeBuffer[i] = random();
|
||||
writeBuffer[i] = static_cast<uint8_t>(random());
|
||||
}
|
||||
|
||||
VerifyOrQuit((message = Thread::Message::New(Thread::Message::kTypeIp6, 0)) != NULL,
|
||||
|
||||
@@ -110,7 +110,7 @@ void DumpBuffer(const char *aTextMessage, uint8_t *aBuffer, uint16_t aBufferLeng
|
||||
{
|
||||
byte = *aBuffer++;
|
||||
printf("%02X ", byte);
|
||||
charBuff[counter] = isprint(byte) ? byte : '.';
|
||||
charBuff[counter] = isprint(byte) ? static_cast<char>(byte) : '.';
|
||||
counter++;
|
||||
|
||||
if (counter == kBytesPerLine)
|
||||
|
||||
@@ -40,7 +40,7 @@ void otTestHexToVector(std::string &aHex, std::vector<uint8_t> &aOutBytes)
|
||||
|
||||
while (ss >> word)
|
||||
{
|
||||
uint8_t n = strtol(word.data(), NULL, 16);
|
||||
uint8_t n = static_cast<uint8_t>(strtol(word.data(), NULL, 16));
|
||||
aOutBytes.push_back(n);
|
||||
}
|
||||
}
|
||||
@@ -63,12 +63,12 @@ void otTestPrintHex(uint8_t *aBuffer, int aLength)
|
||||
|
||||
void otTestPrintHex(std::string &aString)
|
||||
{
|
||||
otTestPrintHex((uint8_t *)aString.data(), aString.size());
|
||||
otTestPrintHex((uint8_t *)aString.data(), static_cast<int>(aString.size()));
|
||||
}
|
||||
|
||||
void otTestPrintHex(std::vector<uint8_t> &aBytes)
|
||||
{
|
||||
otTestPrintHex((uint8_t *)&aBytes[0], aBytes.size());
|
||||
otTestPrintHex((uint8_t *)&aBytes[0], static_cast<int>(aBytes.size()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user