]> wolfpit.net Git - tool/Arch-pacman/.git/commitdiff
query_fileowner: remove useless path variable
authorAndrew Gregory <andrew.gregory.8@gmail.com>
Wed, 19 Jun 2013 05:23:19 +0000 (01:23 -0400)
committerAllan McRae <allan@archlinux.org>
Wed, 26 Jun 2013 05:32:16 +0000 (15:32 +1000)
We no longer need it for resolving package files and using it to
resolve root is unnecessary as alpm does that for us.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
src/pacman/query.c

index 25a3c5d282b4796ed41e0217d88b5fd8b2c08265..f27c5c29664692d0abb703da5c8061dfb08b4eb7 100644 (file)
@@ -136,8 +136,8 @@ cleanup:
 static int query_fileowner(alpm_list_t *targets)
 {
        int ret = 0;
-       char path[PATH_MAX];
-       size_t rootlen;
+       const char *root = alpm_option_get_root(config->handle);
+       size_t rootlen = strlen(root);
        alpm_list_t *t;
        alpm_db_t *db_local;
        alpm_list_t *packages;
@@ -148,30 +148,6 @@ static int query_fileowner(alpm_list_t *targets)
                return 1;
        }
 
-       /* Set up our root path buffer. We only need to copy the location of root in
-        * once, then we can just overwrite whatever file was there on the previous
-        * iteration. */
-
-       /* resolve root now so any symlinks in it will only have to be resolved once */
-       if(!realpath(alpm_option_get_root(config->handle), path)) {
-               pm_printf(ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"),
-                               path, strerror(errno));
-               return 1;
-       }
-
-       /* make sure there's enough room to append the package file to path */
-       rootlen = strlen(path);
-       if(rootlen + 2 > PATH_MAX) {
-               pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), path, "");
-               return 1;
-       }
-
-       /* append trailing '/' removed by realpath */
-       if(path[rootlen - 1] != '/') {
-               path[rootlen++] = '/';
-               path[rootlen] = '\0';
-       }
-
        db_local = alpm_get_localdb(config->handle);
        packages = alpm_db_get_pkgcache(db_local);
 
@@ -214,7 +190,7 @@ static int query_fileowner(alpm_list_t *targets)
                        goto targcleanup;
                }
 
-               if(strncmp(rpath, path, rootlen) != 0) {
+               if(strncmp(rpath, root, rootlen) != 0) {
                        /* file is outside root, we know nothing can own it */
                        pm_printf(ALPM_LOG_ERROR, _("No package owns %s\n"), filename);
                        goto targcleanup;