[toolchain] fix warnings/errors in Keil compiler (#2286)

This commit is contained in:
Łukasz Duda
2017-10-25 08:54:17 -07:00
committed by Jonathan Hui
parent 28d08916a5
commit 7b084eca71
22 changed files with 125 additions and 46 deletions
@@ -30,4 +30,4 @@
#if defined(__ICCARM__)
_Pragma("diag_suppress=Pe549")
#endif
#endif
@@ -35,6 +35,10 @@
extern "C" {
#endif
#if defined(__CC_ARM)
#pragma anon_unions
#endif
/**
* \brief SHA-256 context structure
*/
@@ -51,6 +55,10 @@ typedef union
}
mbedtls_sha256_context;
#if defined(__CC_ARM)
#pragma no_anon_unions
#endif
/**
* @brief Initialize SHA-256 context
*
+33 -9
View File
@@ -40,31 +40,55 @@
#include "platform-nrf5.h"
extern uint32_t __flash_data_start;
extern uint32_t __flash_data_end;
#define FLASH_PAGE_ADDR_MASK 0xFFFFF000
#define FLASH_PAGE_SIZE 4096
#define FLASH_START_ADDR ((uint32_t)&__flash_data_start)
#define FLASH_END_ADDR ((uint32_t)&__flash_data_end)
static uint32_t sFlashDataStart;
static uint32_t sFlashDataEnd;
static inline uint32_t mapAddress(uint32_t aAddress)
{
return aAddress + FLASH_START_ADDR;
return aAddress + sFlashDataStart;
}
otError utilsFlashInit(void)
{
#if defined(__CC_ARM)
// Temporary solution for Keil compiler.
uint32_t const bootloaderAddr = NRF_UICR->NRFFW[0];
uint32_t const pageSize = NRF_FICR->CODEPAGESIZE;
uint32_t const codeSize = NRF_FICR->CODESIZE;
if (bootloaderAddr != 0xFFFFFFFF)
{
sFlashDataEnd = bootloaderAddr;
}
else
{
sFlashDataEnd = pageSize * codeSize;
}
sFlashDataStart = sFlashDataEnd - (pageSize * SETTINGS_CONFIG_PAGE_NUM);
#elif defined(__GNUC__) || defined(__ICCARM__)
extern uint32_t __flash_data_start;
extern uint32_t __flash_data_end;
sFlashDataStart = (uint32_t)&__flash_data_start;
sFlashDataEnd = (uint32_t)&__flash_data_end;
#endif
// Just ensure that the start and end addresses are page-aligned.
assert((FLASH_START_ADDR % FLASH_PAGE_SIZE) == 0);
assert((FLASH_END_ADDR % FLASH_PAGE_SIZE) == 0);
assert((sFlashDataStart % FLASH_PAGE_SIZE) == 0);
assert((sFlashDataEnd % FLASH_PAGE_SIZE) == 0);
return OT_ERROR_NONE;
}
uint32_t utilsFlashGetSize(void)
{
return FLASH_END_ADDR - FLASH_START_ADDR;
return sFlashDataEnd - sFlashDataStart;
}
otError utilsFlashErasePage(uint32_t aAddress)
@@ -156,4 +156,12 @@
*/
#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS 2048
/*
* Suppress the ARMCC warning on unreachable statement,
* e.g. break after assert(false) or ExitNow() macro.
*/
#if defined(__CC_ARM)
_Pragma("diag_suppress=111")
#endif
#endif // OPENTHREAD_CORE_NRF52840_CONFIG_H_
+11
View File
@@ -94,3 +94,14 @@ __WEAK void PlatformEventSignalPending(void)
{
// Intentionally empty
}
#if defined(__CC_ARM)
__WEAK void __aeabi_assert(const char *aExpr, const char *aFile, int aLine)
{
(void) aExpr;
(void) aFile;
(void) aLine;
while (1);
}
#endif
+2 -2
View File
@@ -35,7 +35,7 @@
#ifndef SOFTDEVICE_H_
#define SOFTDEVICE_H_
#if defined ( __GNUC__ )
#if defined(__GNUC__)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"")
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
@@ -47,7 +47,7 @@
#include <nrf_soc.h>
#include <nrf_nvic.h>
#if defined ( __GNUC__ )
#if defined(__GNUC__)
_Pragma("GCC diagnostic pop")
#endif
@@ -33,9 +33,7 @@
*/
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <openthread/config.h>
+2 -2
View File
@@ -86,12 +86,12 @@ struct otIcmp6Header
uint8_t mType; ///< Type
uint8_t mCode; ///< Code
uint16_t mChecksum; ///< Checksum
union
union OT_TOOL_PACKED_FIELD
{
uint8_t m8[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint8_t)];
uint16_t m16[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint16_t)];
uint32_t m32[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint32_t)];
} mData; ///< Message-specific data
} mData; ///< Message-specific data
} OT_TOOL_PACKED_END;
/**
+12
View File
@@ -246,6 +246,18 @@ extern "C" {
CODE \
_Pragma("diag_default=Pe111")
#elif defined(__CC_ARM)
#include <stddef.h>
#define OT_UNUSED_VARIABLE(VARIABLE) \
do \
{ \
if (&VARIABLE == NULL) {} \
} while (false)
#define OT_UNREACHABLE_CODE(CODE) CODE
#else
#define OT_UNUSED_VARIABLE(VARIABLE) \
+9 -3
View File
@@ -416,7 +416,7 @@ typedef struct otExtAddress
OT_TOOL_PACKED_BEGIN
struct otIp6Address
{
union
union OT_TOOL_PACKED_FIELD
{
uint8_t m8[OT_IP6_ADDRESS_SIZE]; ///< 8-bit fields
uint16_t m16[OT_IP6_ADDRESS_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
@@ -693,11 +693,17 @@ enum
/**
* This structure represents an IPv6 prefix.
*/
typedef struct otIp6Prefix
OT_TOOL_PACKED_BEGIN
struct otIp6Prefix
{
otIp6Address mPrefix; ///< The IPv6 prefix.
uint8_t mLength; ///< The IPv6 prefix length.
} otIp6Prefix;
} OT_TOOL_PACKED_END;
/**
* This type represents an IPv6 prefix.
*/
typedef struct otIp6Prefix otIp6Prefix;
#define OT_NETWORK_DATA_ITERATOR_INIT 0 ///< Initializer for otNetworkDataIterator.
+12 -6
View File
@@ -470,11 +470,13 @@ void Interpreter::ProcessChild(int argc, char *argv[])
otError error = OT_ERROR_NONE;
otChildInfo childInfo;
long value;
bool isTable = false;
bool isTable;
VerifyOrExit(argc > 0, error = OT_ERROR_PARSE);
if (strcmp(argv[0], "list") == 0 || (isTable = (strcmp(argv[0], "table") == 0)))
isTable = (strcmp(argv[0], "table") == 0);
if (isTable || strcmp(argv[0], "list") == 0)
{
if (isTable)
{
@@ -1412,12 +1414,14 @@ void Interpreter::ProcessNeighbor(int argc, char *argv[])
{
otError error = OT_ERROR_NONE;
otNeighborInfo neighborInfo;
bool isTable = false;
bool isTable;
otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT;
VerifyOrExit(argc > 0, error = OT_ERROR_PARSE);
if (strcmp(argv[0], "list") == 0 || (isTable = (strcmp(argv[0], "table") == 0)))
isTable = (strcmp(argv[0], "table") == 0);
if (isTable || strcmp(argv[0], "list") == 0)
{
if (isTable)
{
@@ -2224,11 +2228,13 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
otError error = OT_ERROR_NONE;
otRouterInfo routerInfo;
long value;
bool isTable = false;
bool isTable;
VerifyOrExit(argc > 0, error = OT_ERROR_PARSE);
if (strcmp(argv[0], "list") == 0 || (isTable = (strcmp(argv[0], "table") == 0)))
isTable = (strcmp(argv[0], "table") == 0);
if (isTable || strcmp(argv[0], "list") == 0)
{
if (isTable)
{
+2 -2
View File
@@ -68,7 +68,7 @@ public:
* @returns The number of bytes placed in the output queue.
*
*/
int Output(const char *aBuf, uint16_t aBufLength);
virtual int Output(const char *aBuf, uint16_t aBufLength);
/**
* This method delivers formatted output to the client.
@@ -79,7 +79,7 @@ public:
* @returns The number of bytes placed in the output queue.
*
*/
int OutputFormat(const char *fmt, ...);
virtual int OutputFormat(const char *fmt, ...);
/**
* This method sets a callback that is called when console has some output.
+1 -1
View File
@@ -199,7 +199,7 @@ public:
* @param[in] aMessageInfo A reference to the message info associated with @p aMessage.
*
*/
void Receive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
virtual void Receive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
private:
virtual otError Send(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
+1 -2
View File
@@ -174,7 +174,6 @@ struct Address
* This class implements IEEE 802.15.4 MAC frame generation and parsing.
*
*/
OT_TOOL_PACKED_BEGIN
class Frame: public otRadioFrame
{
public:
@@ -827,7 +826,7 @@ private:
static uint8_t GetKeySourceLength(uint8_t aKeyIdMode);
} OT_TOOL_PACKED_END;
};
OT_TOOL_PACKED_BEGIN
class Beacon
+1 -1
View File
@@ -428,7 +428,7 @@ otError Dhcp6Server::SendReply(otIp6Address &aDst, uint8_t *aTransactionId, Clie
SuccessOrExit(error = AppendRapidCommit(*message));
memset(&messageInfo, 0, sizeof(messageInfo));
memcpy(&messageInfo.GetPeerAddr().mFields.m8, &aDst, sizeof(otIp6Address));
memcpy(messageInfo.GetPeerAddr().mFields.m8, &aDst, sizeof(otIp6Address));
messageInfo.mPeerPort = kDhcpClientPort;
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
+1 -1
View File
@@ -115,7 +115,7 @@ enum
OT_TOOL_PACKED_BEGIN
struct HeaderPoD
{
union
union OT_TOOL_PACKED_FIELD
{
uint8_t m8[kVersionClassFlowSize / sizeof(uint8_t)];
uint16_t m16[kVersionClassFlowSize / sizeof(uint16_t)];
+1 -1
View File
@@ -1178,7 +1178,7 @@ otError FragmentHeader::Init(const uint8_t *aFrame, uint8_t aFrameLength)
otError error = OT_ERROR_PARSE;
VerifyOrExit(aFrameLength >= sizeof(mDispatchSize) + sizeof(mTag));
memcpy(&mDispatchSize, aFrame, sizeof(mDispatchSize) + sizeof(mTag));
memcpy(reinterpret_cast<uint8_t *>(&mDispatchSize), aFrame, sizeof(mDispatchSize) + sizeof(mTag));
aFrame += sizeof(mDispatchSize) + sizeof(mTag);
aFrameLength -= sizeof(mDispatchSize) + sizeof(mTag);
+2 -2
View File
@@ -378,11 +378,11 @@ private:
uint8_t mDispatchHopsLeft;
uint8_t mDeepHopsLeft;
struct
struct OT_TOOL_PACKED_FIELD
{
uint16_t mSource;
uint16_t mDestination;
} mAddress OT_TOOL_PACKED_FIELD;
} mAddress;
} OT_TOOL_PACKED_END;
/**
+2 -3
View File
@@ -97,7 +97,6 @@ void ChildSupervisor::SendMessage(Child &aChild)
{
ThreadNetif &netif = GetNetif();
Message *message = NULL;
otError error = OT_ERROR_NONE;
uint8_t childIndex;
VerifyOrExit(aChild.GetIndirectMessageCount() == 0);
@@ -111,9 +110,9 @@ void ChildSupervisor::SendMessage(Child &aChild)
// `ChildSupervisor::GetDestination(message)`.
childIndex = netif.GetMle().GetChildIndex(aChild);
SuccessOrExit(error = message->Append(&childIndex, sizeof(childIndex)));
SuccessOrExit(message->Append(&childIndex, sizeof(childIndex)));
SuccessOrExit(error = netif.SendMessage(*message));
SuccessOrExit(netif.SendMessage(*message));
message = NULL;
otLogInfoMle(GetInstance(), "Sending supervision message to child 0x%04x", aChild.GetRloc16());
+14 -4
View File
@@ -756,16 +756,18 @@ otError NcpBase::InsertPropertyHandler_THREAD_ON_MESH_NETS(void)
otBorderRouterConfig borderRouterConfig;
bool stable = false;
uint8_t flags = 0;
uint8_t prefixLength;
memset(&borderRouterConfig, 0, sizeof(otBorderRouterConfig));
VerifyOrExit(mAllowLocalNetworkDataChange == true, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = mDecoder.ReadIp6Address(borderRouterConfig.mPrefix.mPrefix));
SuccessOrExit(error = mDecoder.ReadUint8(borderRouterConfig.mPrefix.mLength));
SuccessOrExit(error = mDecoder.ReadUint8(prefixLength));
SuccessOrExit(error = mDecoder.ReadBool(stable));
SuccessOrExit(error = mDecoder.ReadUint8(flags));
borderRouterConfig.mPrefix.mLength = prefixLength;
borderRouterConfig.mStable = stable;
borderRouterConfig.mPreference =
((flags & SPINEL_NET_FLAG_PREFERENCE_MASK) >> SPINEL_NET_FLAG_PREFERENCE_OFFSET);
@@ -786,13 +788,16 @@ otError NcpBase::RemovePropertyHandler_THREAD_ON_MESH_NETS(void)
{
otError error = OT_ERROR_NONE;
otIp6Prefix ip6Prefix;
uint8_t prefixLength;
memset(&ip6Prefix, 0, sizeof(otIp6Prefix));
VerifyOrExit(mAllowLocalNetworkDataChange == true, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = mDecoder.ReadIp6Address(ip6Prefix.mPrefix));
SuccessOrExit(error = mDecoder.ReadUint8(ip6Prefix.mLength));
SuccessOrExit(error = mDecoder.ReadUint8(prefixLength));
ip6Prefix.mLength = prefixLength;
error = otBorderRouterRemoveOnMeshPrefix(mInstance, &ip6Prefix);
@@ -1131,16 +1136,18 @@ otError NcpBase::InsertPropertyHandler_THREAD_OFF_MESH_ROUTES(void)
otExternalRouteConfig routeConfig;
bool stable = false;
uint8_t flags = 0;
uint8_t prefixLength;
memset(&routeConfig, 0, sizeof(otExternalRouteConfig));
VerifyOrExit(mAllowLocalNetworkDataChange == true, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = mDecoder.ReadIp6Address(routeConfig.mPrefix.mPrefix));
SuccessOrExit(error = mDecoder.ReadUint8(routeConfig.mPrefix.mLength));
SuccessOrExit(error = mDecoder.ReadUint8(prefixLength));
SuccessOrExit(error = mDecoder.ReadBool(stable));
SuccessOrExit(error = mDecoder.ReadUint8(flags));
routeConfig.mPrefix.mLength = prefixLength;
routeConfig.mStable = stable;
routeConfig.mPreference = FlagByteToExternalRoutePreference(flags);
@@ -1154,13 +1161,16 @@ otError NcpBase::RemovePropertyHandler_THREAD_OFF_MESH_ROUTES(void)
{
otError error = OT_ERROR_NONE;
otIp6Prefix ip6Prefix;
uint8_t prefixLength;
memset(&ip6Prefix, 0, sizeof(otIp6Prefix));
VerifyOrExit(mAllowLocalNetworkDataChange == true, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = mDecoder.ReadIp6Address(ip6Prefix.mPrefix));
SuccessOrExit(error = mDecoder.ReadUint8(ip6Prefix.mLength));
SuccessOrExit(error = mDecoder.ReadUint8(prefixLength));
ip6Prefix.mLength = prefixLength;
error = otBorderRouterRemoveRoute(mInstance, &ip6Prefix);
@@ -5,10 +5,8 @@
#undef PACKAGE
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//==========================================================
+2 -2
View File
@@ -149,12 +149,12 @@ typedef enum {
#define __FPU_PRESENT 1 /*!< FPU present or not */
/** @} */ /* End of group Configuration_of_CMSIS */
#if defined ( __GNUC__ )
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include "core_cm4.h" /*!< Cortex-M4 processor and core peripherals */
#if defined ( __GNUC__ )
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif