请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC2630 您好!
函数 Zstart_addToBlackList 中的 zstart.c 中似乎存在错误
bool Zstart_addToBlackList (uint8_t *扩展 PANID、uint16_t 路由器) { bool ret = false; //有效性检查 if (pExtendedPANID &&)(memcmp (pExtendedPANID、 dummyPANID、EXT_PANID_LEN)!= 0)) { if (zstart_existBlackList (pExtendedPANID、router)=false) { zstart_BL_Item *pAddItem; pAddItem = iCall_malloc (sizeof (zstart_BL_Item)); if (pAddItem) { zstart_BL_Item *pItem = pBlItems; //生成新条目 memcpy (pAddItem->extendedPANID、pExtendedPANID、 EXT_PANID_LEN); pAddItem->router =路由器; pAddItem->next = NULL; //有问题的代码*/ //查找列表末尾 while (pItem->next) { pItem = pItem->next; } if (pItem) { pItem->next = pAddItem; } 其他 { pBlItems = pAddItem; } /*有问题的代码*/ //向 NV 添加条目 zstart_addBlackListNV (pExtendedPANID、router); RET = true; } } return (ret); }
我用粗体字母表示这些行。 在这种情况下,无需预先检查 pItem 是否存在,即 pItem 是否为空,即可访问 pItem->next。
我认为应该将其更改为
if (pItem) { //查找列表末尾 while (pItem->next) { pItem = pItem->next; } pItem->next = pAddItem; } 其他 { pBlItems = pAddItem; }