Correctly handle failure in getting build or install dates

alpm_pkg_get_builddate() and alpm_pkg_get_installdate() both return -1 on
error. Correctly handle the error condition in pacman.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 7bcc2d9b23)
This commit is contained in:
Allan McRae 2022-07-21 19:50:10 +10:00
parent d55924dbd7
commit 4b21c60e50

View file

@ -210,11 +210,11 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
/* set variables here, do all output below */ /* set variables here, do all output below */
bdate = (time_t)alpm_pkg_get_builddate(pkg); bdate = (time_t)alpm_pkg_get_builddate(pkg);
if(bdate) { if(bdate != -1) {
strftime(bdatestr, 50, "%c", localtime(&bdate)); strftime(bdatestr, 50, "%c", localtime(&bdate));
} }
idate = (time_t)alpm_pkg_get_installdate(pkg); idate = (time_t)alpm_pkg_get_installdate(pkg);
if(idate) { if(idate != -1) {
strftime(idatestr, 50, "%c", localtime(&idate)); strftime(idatestr, 50, "%c", localtime(&idate));
} }