tests: kernel: mbox_api: fix uninit variable and unchecked value
"struct k_mbox_msg mmsg" should be initialized before using. "int" value returned by k_mem_pool_alloc() should be checked. Coverity-CID: 160083 Coverity-CID: 160470 Change-Id: I35714bf9d76723c5fdd8c2963bf76b42ae1b1867 Signed-off-by: Sharron LIU <sharron.liu@intel.com>
This commit is contained in:
parent
d9a3c92b5b
commit
110d58c055
1 changed files with 4 additions and 1 deletions
|
@ -63,6 +63,8 @@ static void tmbox_put(struct k_mbox *pmbox)
|
||||||
{
|
{
|
||||||
struct k_mbox_msg mmsg;
|
struct k_mbox_msg mmsg;
|
||||||
|
|
||||||
|
memset(&mmsg, 0, sizeof(mmsg));
|
||||||
|
|
||||||
switch (info_type) {
|
switch (info_type) {
|
||||||
case PUT_GET_NULL:
|
case PUT_GET_NULL:
|
||||||
/**TESTPOINT: mbox sync put empty message*/
|
/**TESTPOINT: mbox sync put empty message*/
|
||||||
|
@ -104,7 +106,8 @@ static void tmbox_put(struct k_mbox *pmbox)
|
||||||
mmsg.info = ASYNC_PUT_GET_BLOCK;
|
mmsg.info = ASYNC_PUT_GET_BLOCK;
|
||||||
mmsg.size = MAIL_LEN;
|
mmsg.size = MAIL_LEN;
|
||||||
mmsg.tx_data = NULL;
|
mmsg.tx_data = NULL;
|
||||||
k_mem_pool_alloc(&mpooltx, &mmsg.tx_block, MAIL_LEN, K_NO_WAIT);
|
assert_equal(k_mem_pool_alloc(&mpooltx, &mmsg.tx_block,
|
||||||
|
MAIL_LEN, K_NO_WAIT), 0, NULL);
|
||||||
memcpy(mmsg.tx_block.data, data[info_type], MAIL_LEN);
|
memcpy(mmsg.tx_block.data, data[info_type], MAIL_LEN);
|
||||||
if (info_type == TARGET_SOURCE_THREAD_BLOCK) {
|
if (info_type == TARGET_SOURCE_THREAD_BLOCK) {
|
||||||
mmsg.tx_target_thread = receiver_tid;
|
mmsg.tx_target_thread = receiver_tid;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue