1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-02-09 13:46:51 +02:00

Refactor loop in restoreManifestMap() to satisfy Coverity.

Coverity complained that decrementing targetIdx would result in it equaling UINT_MAX. While this is true it had no impact overall (at it least in the current code) since targetIdx was immediately incremented in the loop.

However, Coverity's suggestion is better and safer for future code updates so it makes sense to change it.
This commit is contained in:
David Steele 2025-01-30 13:59:42 -05:00
parent 5421ef3e92
commit 89615eee65

View File

@ -581,7 +581,9 @@ restoreManifestMap(Manifest *const manifest)
// If all links are not being restored then check for links that were not remapped and remove them
if (!cfgOptionBool(cfgOptLinkAll))
{
for (unsigned int targetIdx = 0; targetIdx < manifestTargetTotal(manifest); targetIdx++)
unsigned int targetIdx = 0;
while (targetIdx < manifestTargetTotal(manifest))
{
const ManifestTarget *const target = manifestTarget(manifest, targetIdx);
@ -603,9 +605,11 @@ restoreManifestMap(Manifest *const manifest)
manifestLinkRemove(manifest, target->name);
manifestTargetRemove(manifest, target->name);
targetIdx--;
continue;
}
}
targetIdx++;
}
}
}