1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

query check: use provided filelist count instead of keeping track

We don't need to keep track of how many files are in a package now that
said value is provided to us. It also makes more sense to use size_t
here for types rather than the (hopefully never too short) int.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-09-07 20:41:09 -05:00
parent 6317db8429
commit b961ebe16f

View File

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -405,7 +406,7 @@ static int filter(alpm_pkg_t *pkg)
static int check(alpm_pkg_t *pkg) static int check(alpm_pkg_t *pkg)
{ {
const char *root, *pkgname; const char *root, *pkgname;
int allfiles = 0, errors = 0; size_t errors = 0;
size_t rootlen; size_t rootlen;
char f[PATH_MAX]; char f[PATH_MAX];
alpm_filelist_t *filelist; alpm_filelist_t *filelist;
@ -432,7 +433,6 @@ static int check(alpm_pkg_t *pkg)
continue; continue;
} }
strcpy(f + rootlen, path); strcpy(f + rootlen, path);
allfiles++;
/* use lstat to prevent errors from symlinks */ /* use lstat to prevent errors from symlinks */
if(lstat(f, &st) != 0) { if(lstat(f, &st) != 0) {
if(config->quiet) { if(config->quiet) {
@ -446,10 +446,10 @@ static int check(alpm_pkg_t *pkg)
} }
if(!config->quiet) { if(!config->quiet) {
printf(_n("%s: %d total file, ", "%s: %d total files, ", printf(_n("%s: %jd total file, ", "%s: %jd total files, ",
(unsigned long)allfiles), pkgname, allfiles); (unsigned long)filelist->count), pkgname, (intmax_t)filelist->count);
printf(_n("%d missing file\n", "%d missing files\n", printf(_n("%jd missing file\n", "%jd missing files\n",
(unsigned long)errors), errors); (unsigned long)errors), (intmax_t)errors);
} }
return (errors != 0 ? 1 : 0); return (errors != 0 ? 1 : 0);