Skip to content

Commit f078b44

Browse files
committed
Fix return value
Make Delete return the same errors as before the changes. Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
1 parent 833378a commit f078b44

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/credentials/FabricTable.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -1046,12 +1046,17 @@ CHIP_ERROR FabricTable::Delete(FabricIndex fabricIndex)
10461046
}
10471047
}
10481048

1049-
// Only return error after trying really hard to remove everything we could
1050-
ReturnErrorOnFailure(metadataErr);
1051-
ReturnErrorOnFailure(opKeyErr);
1052-
ReturnErrorOnFailure(opCertsErr);
1049+
if (fabricIsInitialized)
1050+
{
1051+
// Only return error after trying really hard to remove everything we could
1052+
ReturnErrorOnFailure(metadataErr);
1053+
ReturnErrorOnFailure(opKeyErr);
1054+
ReturnErrorOnFailure(opCertsErr);
10531055

1054-
return CHIP_NO_ERROR;
1056+
return CHIP_NO_ERROR;
1057+
}
1058+
1059+
return CHIP_ERROR_NOT_FOUND;
10551060
}
10561061

10571062
void FabricTable::DeleteAllFabrics()

src/credentials/FabricTable.h

+1
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ class DLL_EXPORT FabricTable
417417
*
418418
* @param fabricIndex - Index of fabric for deletion
419419
* @retval CHIP_NO_ERROR on success
420+
* @retval CHIP_ERROR_NOT_FOUND if there is no fabric for that index
420421
* @retval CHIP_ERROR_INVALID_ARGUMENT if any of the arguments are invalid such as too large or out of bounds
421422
* @retval other CHIP_ERROR on internal errors
422423
*/

0 commit comments

Comments
 (0)