Skip to content

Commit

Permalink
Do not modify index if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Nov 10, 2021
1 parent c6b45eb commit 010d5cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions indidriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
XMLEle *root = NULL, *fproot = NULL;
char errmsg[MAXRBUF];
LilXML *lp = newLilXML();
*index = -1;
int valueFound = 0;

FILE *fp = IUGetConfigFP(NULL, dev, "r", errmsg);

Expand Down Expand Up @@ -1312,6 +1312,7 @@ int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
if (crackISState(pcdataXMLEle(oneSwitch), &s) == 0 && s == ISS_ON)
{
*index = currentIndex;
valueFound = 1;
break;
}
}
Expand All @@ -1323,7 +1324,7 @@ int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
delXMLEle(fproot);
delLilXML(lp);

return (*index >= 0 ? 0 : -1);
return (valueFound == 1 ? 0 : -1);
}

int IUGetConfigOnSwitchLabel(const char *dev, const char *property, char *label, size_t size)
Expand Down

0 comments on commit 010d5cf

Please sign in to comment.