Hi all,
Is the following code snippet safe?
Trying to iterate and delete rows which matches one of the keys.
struct maapi_cursor mc;
maapi_init_cursor(msock, th, &mc, path);
maapi_get_next(&mc);
while (mc.n)
{
if (CONFD_GET_XXX(&mc.keys[0]) == somevalue)
{
// Delete row
maapi_delete(msock, th, path"{%x %x}", &mc.keys[0], &mc.keys[1]);
}
maapi_get_next(&mc);
}
In one case, we are seeing there are multiple entries with the matching condition, but the iteration code deletes only one row.
But we have this code pattern in multiple places but similar issues were not reported before. That makes me wonder whether the above pattern is safe or not.
Regards,