pgbackrest.git / summary / log / commit / refs

commit    89615eee654388ea046812bfaa30d514b269c5d1
Author:   David Steele <david@pgbackrest.org>
Date:     Thu Jan 30 18:59:42 2025 +0000

    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.


src/command/restore/restore.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/command/restore/restore.c b/src/command/restore/restore.c index d42e51acf..d9f5b7b84 100644 --- a/src/command/restore/restore.c +++ b/src/command/restore/restore.c @@ -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++; } } } [parent: 5421ef3e92fb]