Make adding an identical error symbol not fail

A test case was also added which test that adding an error symbol
with same error code and message as one added before will not fail
This commit is contained in:
Emilio Perez
2023-03-09 16:05:07 +00:00
committed by Dirk Zimoch
parent c680b9bebd
commit e6dab90bf4
2 changed files with 16 additions and 2 deletions
+6 -1
View File
@@ -105,7 +105,12 @@ int errSymbolAdd(long errNum, const char *name)
/* search for last node (NULL) of hashnode linked list */
while (pNextNode) {
if (pNextNode->errNum == errNum) {
return S_err_codeExists;
if(strcmp(name, pNextNode->message)) {
return S_err_codeExists;
}
else {
return 0;
}
}
phashnode = &pNextNode->hashnode;
pNextNode = *phashnode;
+10 -1
View File
@@ -238,13 +238,21 @@ static void testAddingExistingErrorSymbol()
"Adding an error symbol with an existing error code should fail");
}
static void testAddingExistingErrorSymbolWithSameMessage()
{
long invented_code = (0x7999 << 16) | 0x9997;
errSymbolAdd(invented_code, "Invented Error Message");
testOk(!errSymbolAdd(invented_code, "Invented Error Message"),
"Adding identical error symbol shouldn't fail");
}
MAIN(epicsErrlogTest)
{
size_t mlen, i, N;
char msg[256];
clientPvt pvt, pvt2;
testPlan(53);
testPlan(54);
testANSIStrip();
@@ -460,6 +468,7 @@ MAIN(epicsErrlogTest)
testAddingErrorSymbol();
testAddingInvalidErrorSymbol();
testAddingExistingErrorSymbol();
testAddingExistingErrorSymbolWithSameMessage();
return testDone();
}