MISRA-related fixes.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11455 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2018-02-06 18:15:51 +00:00
parent 069482ac06
commit a947a1d5ae
6 changed files with 23 additions and 25 deletions

View File

@ -111,11 +111,11 @@
#error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MEMCORE"
#endif
#if (CH_FACTORY_REQUIRES_POOLS == TRUE) && (CH_CFG_USE_MEMPOOLS == FALSE)
#if CH_FACTORY_REQUIRES_POOLS && (CH_CFG_USE_MEMPOOLS == FALSE)
#error "CH_CFG_USE_MEMPOOLS is required"
#endif
#if (CH_FACTORY_REQUIRES_HEAP == TRUE) && (CH_CFG_USE_HEAP == FALSE)
#if CH_FACTORY_REQUIRES_HEAP && (CH_CFG_USE_HEAP == FALSE)
#error "CH_CFG_USE_HEAP is required"
#endif
@ -187,11 +187,13 @@ typedef struct ch_dyn_object {
* @brief List element of the dynamic buffer object.
*/
dyn_element_t element;
/*lint -save -e9038 [18.7] Required by design.*/
/**
* @brief The buffer.
* @note This requires C99.
*/
uint8_t buffer[];
/*lint restore*/
} dyn_buffer_t;
#endif
@ -224,11 +226,13 @@ typedef struct ch_dyn_mailbox {
* @brief The mailbox.
*/
mailbox_t mbx;
/**
/*lint -save -e9038 [18.7] Required by design.*/
/**
* @brief Messages buffer.
* @note This requires C99.
*/
msg_t msgbuf[];
/*lint restore*/
} dyn_mailbox_t;
#endif
@ -245,6 +249,7 @@ typedef struct ch_dyn_objects_fifo {
* @brief The objects FIFO.
*/
objects_fifo_t fifo;
/*lint -save -e9038 [18.7] Required by design.*/
/**
* @brief Messages buffer.
* @note This open array is followed by another area containing the
@ -252,6 +257,7 @@ typedef struct ch_dyn_objects_fifo {
* @note This requires C99.
*/
msg_t msgbuf[];
/*lint restore*/
} dyn_objects_fifo_t;
#endif

View File

@ -120,7 +120,7 @@ static dyn_element_t *dyn_list_unlink(dyn_element_t *element,
return NULL;
}
#if (CH_FACTORY_REQUIRES_HEAP == TRUE) || defined(__DOXYGEN__)
#if CH_FACTORY_REQUIRES_HEAP || defined(__DOXYGEN__)
static dyn_element_t *dyn_create_object_heap(const char *name,
dyn_list_t *dlp,
size_t size) {
@ -142,7 +142,7 @@ static dyn_element_t *dyn_create_object_heap(const char *name,
/* Initializing object list element.*/
strncpy(dep->name, name, CH_CFG_FACTORY_MAX_NAMES_LENGTH);
dep->refs = 1U;
dep->refs = (ucnt_t)1;
dep->next = dlp->next;
/* Updating factory list.*/
@ -155,18 +155,18 @@ static void dyn_release_object_heap(dyn_element_t *dep,
dyn_list_t *dlp) {
chDbgCheck(dep != NULL);
chDbgAssert(dep->refs > 0U, "invalid references number");
chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number");
dep->refs--;
if (dep->refs == 0U) {
if (dep->refs == (ucnt_t)0) {
dep = dyn_list_unlink(dep, dlp);
chHeapFree((void *)dep);
}
}
#endif /* CH_FACTORY_REQUIRES_HEAP == TRUE */
#endif /* CH_FACTORY_REQUIRES_HEAP */
#if (CH_FACTORY_REQUIRES_POOLS == TRUE) || defined(__DOXYGEN__)
#if CH_FACTORY_REQUIRES_POOLS || defined(__DOXYGEN__)
static dyn_element_t *dyn_create_object_pool(const char *name,
dyn_list_t *dlp,
memory_pool_t *mp) {
@ -188,7 +188,7 @@ static dyn_element_t *dyn_create_object_pool(const char *name,
/* Initializing object list element.*/
strncpy(dep->name, name, CH_CFG_FACTORY_MAX_NAMES_LENGTH);
dep->refs = 1U;
dep->refs = (ucnt_t)1;
dep->next = dlp->next;
/* Updating factory list.*/
@ -202,15 +202,15 @@ static void dyn_release_object_pool(dyn_element_t *dep,
memory_pool_t *mp) {
chDbgCheck(dep != NULL);
chDbgAssert(dep->refs > 0U, "invalid references number");
chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number");
dep->refs--;
if (dep->refs == 0U) {
if (dep->refs == (ucnt_t)0) {
dep = dyn_list_unlink(dep, dlp);
chPoolFree(mp, (void *)dep);
}
}
#endif /* CH_FACTORY_REQUIRES_POOLS == TRUE */
#endif /* CH_FACTORY_REQUIRES_POOLS */
static dyn_element_t *dyn_find_object(const char *name, dyn_list_t *dlp) {
dyn_element_t *dep;

View File

@ -135,7 +135,9 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) {
/* Adjusting the size in case the initial block was not correctly
aligned.*/
/*lint -save -e9033 [10.8] Required cast operations.*/
size -= (size_t)((uint8_t *)hp - (uint8_t *)buf);
/*lint restore*/
/* Initializing the heap header.*/
heapp->provider = NULL;

View File

@ -283,7 +283,6 @@ extern stkalign_t ch_idle_thread_wa[];
extern "C" {
#endif
void chSysInit(void);
void chSysHalt(const char *reason);
bool chSysIntegrityCheckI(unsigned testmask);
void chSysTimerHandlerI(void);
syssts_t chSysGetStatusAndLockX(void);

View File

@ -281,7 +281,7 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {
thread_t *tp;
#if (CH_CFG_USE_REGISTRY == TRUE) && \
(CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
chDbgAssert(chRegFindThreadByWorkingArea(tdp->wbase) == NULL,
"working area in use");
#endif
@ -331,7 +331,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
(prio <= HIGHPRIO) && (pf != NULL));
#if (CH_CFG_USE_REGISTRY == TRUE) && \
(CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
chDbgAssert(chRegFindThreadByWorkingArea(wsp) == NULL,
"working area in use");
#endif

View File

@ -571,15 +571,6 @@
#define CH_CFG_SYSTEM_EXTRA_FIELDS \
/* Add threads custom fields here.*/
/**
* @brief System initialization hook.
* @details User initialization code added to the @p chSysInit() function
* just before interrupts are enabled globally.
*/
#define CH_CFG_SYSTEM_INIT_HOOK(tp) { \
/* Add threads initialization code here.*/ \
}
/**
* @brief Threads descriptor structure extension.
* @details User fields added to the end of the @p thread_t structure.