@@ -322,9 +322,10 @@ struct FabricEntryData : public PersistableData<kFabricMaxBytes>
322322 }
323323
324324 // / @brief Finds the index where the current entry should be inserted by going through the endpoint's table and checking
325- // / whether the entry is already there. If the target is not in the table, sets idx to the first empty space
326- // / @param target_entry StorageId of entry to find
327- // / @param idx Index where target or space is found
325+ // / whether the entry is already there. If the target is not in the table, sets idx to the first empty space.
326+ // / If the target was not found and the table is full, sets idx to kUndefinedEntryIndex.
327+ // / @param[in] target_entry StorageId of entry to find
328+ // / @param[out] idx Index where target or space is found.
328329 // / @return CHIP_NO_ERROR if managed to find the target entry, CHIP_ERROR_NOT_FOUND if not found and space left
329330 // / CHIP_ERROR_NO_MEMORY if target was not found and table is full
330331 CHIP_ERROR Find (const StorageId & target_entry, EntryIndex & idx)
@@ -351,7 +352,7 @@ struct FabricEntryData : public PersistableData<kFabricMaxBytes>
351352 idx = firstFreeIdx;
352353 return CHIP_ERROR_NOT_FOUND ;
353354 }
354-
355+ idx = Data:: kUndefinedEntryIndex ;
355356 return CHIP_ERROR_NO_MEMORY ;
356357 }
357358
@@ -360,8 +361,8 @@ struct FabricEntryData : public PersistableData<kFabricMaxBytes>
360361 CHIP_ERROR err = CHIP_NO_ERROR ;
361362 // Look for empty storage space
362363
363- EntryIndex index;
364- err = this ->Find (id, index);
364+ EntryIndex index = Data:: kUndefinedEntryIndex ;
365+ err = this ->Find (id, index);
365366
366367 // C++ doesn't have const constructors; variable is declared const
367368 const TypedTableEntryData entry (endpoint_id, fabric_index, const_cast <StorageId &>(id), const_cast <StorageData &>(data),
0 commit comments