Enable -Wconversion on clang and fix all warnings. (#358)

This commit is contained in:
Jonathan Hui
2016-08-10 11:52:22 -07:00
committed by GitHub
parent c7f62aa235
commit 4050c68577
59 changed files with 503 additions and 436 deletions
+3 -3
View File
@@ -50,7 +50,7 @@ uint32_t otPlatAlarmGetNow(void)
gettimeofday(&tv, NULL);
timersub(&tv, &s_start, &tv);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
return (uint32_t)((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
}
void otPlatAlarmStartAt(uint32_t t0, uint32_t dt)
@@ -75,7 +75,7 @@ void posixAlarmUpdateTimeout(struct timeval *aTimeout)
if (s_is_running)
{
remaining = s_alarm - otPlatAlarmGetNow();
remaining = (int32_t)(s_alarm - otPlatAlarmGetNow());
if (remaining > 0)
{
@@ -101,7 +101,7 @@ void posixAlarmProcess(void)
if (s_is_running)
{
remaining = s_alarm - otPlatAlarmGetNow();
remaining = (int32_t)(s_alarm - otPlatAlarmGetNow());
if (remaining <= 0)
{
+1 -1
View File
@@ -43,7 +43,7 @@
#define LOG_PRINTF(...) \
charsWritten = snprintf(&logString[index], sizeof(logString) - index , __VA_ARGS__); \
VerifyOrExit(charsWritten >= 0, logString[index] = 0); \
index += charsWritten; \
index += (unsigned int)charsWritten; \
VerifyOrExit(index < sizeof(logString), logString[sizeof(logString) -1 ] = 0)
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
+1 -1
View File
@@ -57,7 +57,7 @@ void PlatformInit(int argc, char *argv[])
exit(1);
}
NODE_ID = strtol(argv[1], &endptr, 0);
NODE_ID = (uint32_t)strtol(argv[1], &endptr, 0);
if (*endptr != '\0')
{
+6 -6
View File
@@ -238,12 +238,12 @@ static inline uint8_t getDsn(const uint8_t *frame)
static inline otPanId getDstPan(const uint8_t *frame)
{
return (((otPanId)frame[IEEE802154_DSTPAN_OFFSET + 1]) << 8) | frame[IEEE802154_DSTPAN_OFFSET];
return (otPanId)((frame[IEEE802154_DSTPAN_OFFSET + 1] << 8) | frame[IEEE802154_DSTPAN_OFFSET]);
}
static inline otShortAddress getShortAddress(const uint8_t *frame)
{
return (((otShortAddress)frame[IEEE802154_DSTADDR_OFFSET + 1]) << 8) | frame[IEEE802154_DSTADDR_OFFSET];
return (otShortAddress)((frame[IEEE802154_DSTADDR_OFFSET + 1] << 8) | frame[IEEE802154_DSTADDR_OFFSET]);
}
static inline void getExtAddress(const uint8_t *frame, otExtAddress *address)
@@ -319,7 +319,7 @@ void posixRadioInit(void)
{
char *endptr;
sPortOffset = strtol(offset, &endptr, 0);
sPortOffset = (uint16_t)strtol(offset, &endptr, 0);
if (*endptr != '\0')
{
@@ -440,10 +440,10 @@ void radioReceive(void)
{
if (sState != kStateTransmit || sAckWait)
{
int rval = recvfrom(sSockFd, &sReceiveMessage, sizeof(sReceiveMessage), 0, NULL, NULL);
ssize_t rval = recvfrom(sSockFd, &sReceiveMessage, sizeof(sReceiveMessage), 0, NULL, NULL);
assert(rval >= 0);
sReceiveFrame.mLength = rval - 1;
sReceiveFrame.mLength = (uint8_t)(rval - 1);
if (sAckWait &&
sTransmitFrame.mChannel == sReceiveMessage.mChannel &&
@@ -532,7 +532,7 @@ void radioTransmit(const struct RadioMessage *msg, const struct RadioPacket *pkt
for (i = 1; i <= WELLKNOWN_NODE_ID; i++)
{
int rval;
ssize_t rval;
if (NODE_ID == i)
{
+6 -6
View File
@@ -91,13 +91,13 @@ ThreadError otPlatUartEnable(void)
VerifyOrExit(tcgetattr(s_in_fd, &termios) == 0, perror("tcgetattr"); error = kThreadError_Error);
// turn off input processing
termios.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
termios.c_iflag &= ~(unsigned long)(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
// turn off line processing
termios.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
termios.c_lflag &= ~(unsigned long)(ECHO | ECHONL | ICANON | IEXTEN);
// turn off character processing
termios.c_cflag &= ~(CSIZE | PARENB);
termios.c_cflag &= ~(unsigned long)(CSIZE | PARENB);
termios.c_cflag |= CS8 | HUPCL | CREAD | CLOCAL;
// return 1 byte at a time
@@ -122,7 +122,7 @@ ThreadError otPlatUartEnable(void)
termios.c_oflag = 0;
// turn off character processing
termios.c_cflag &= ~(CSIZE | PARENB);
termios.c_cflag &= ~(unsigned long)(CSIZE | PARENB);
termios.c_cflag |= CS8 | HUPCL | CREAD | CLOCAL;
// configure baud rate
@@ -190,13 +190,13 @@ void posixUartProcess(void)
{
const int flags = POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
struct pollfd pollfd = { s_in_fd, flags, 0 };
int rval;
ssize_t rval;
if (poll(&pollfd, 1, 0) > 0 && (pollfd.revents & flags) != 0)
{
rval = read(s_in_fd, s_receive_buffer, sizeof(s_receive_buffer));
assert(rval >= 0);
otPlatUartReceived(s_receive_buffer, rval);
otPlatUartReceived(s_receive_buffer, (uint16_t)rval);
}
if (s_write_length > 0)