1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Modify time_t casts based on complaints from Coverity.

Coverity complained about time_t being cast directly to unsigned int, so instead cast the result of the operation.

We are confident in both cases that the time_t values will not be out of unsigned int range but Coverity has no way to know that.

One of these is new (introduced by 9efd5cd0) but the other one (from a9867cb0) remained unnoticed for a while, though it has not caused any production impact.
This commit is contained in:
David Steele 2023-07-09 21:56:05 +03:00
parent 28b6b2d465
commit aa229a1dee
3 changed files with 7 additions and 4 deletions

View File

@ -73,8 +73,11 @@
</release-item>
<release-item>
<github-issue id="2093"/>
<github-pull-request id="2095"/>
<commit subject="Add timezone offset to info command date/time output.">
<github-issue id="2093"/>
<github-pull-request id="2095"/>
</commit>
<commit subject="Modify time_t casts based on complaint from Coverity."/>
<release-item-contributor-list>
<release-item-ideator id="philip.hurst"/>

View File

@ -442,7 +442,7 @@ backupBlockIncrMap(void)
ManifestBlockIncrAgeMap manifestBuildBlockIncrAgeMap =
{
.fileAge = varUIntForce(mapKey) * (unsigned int)SEC_PER_DAY,
.fileAge = (unsigned int)(varUIntForce(mapKey) * SEC_PER_DAY),
.blockMultiplier = varUIntForce(kvGet(manifestBlockIncrAgeKv, mapKey)),
};

View File

@ -849,7 +849,7 @@ formatTextBackupDateTime(const time_t epoch)
strCatChr(result, '-');
}
const unsigned int minute = (unsigned int)offset / 60;
const unsigned int minute = (unsigned int)(offset / 60);
const unsigned int hour = minute / 60;
strCatFmt(result, "%02u", hour);