From b36b87656ef8e341dccc5c683ed9f814c0017c67 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Wed, 19 Jun 2013 01:23:19 -0400 Subject: query_fileowner: remove useless path variable 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 Signed-off-by: Allan McRae --- src/pacman/query.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src/pacman') diff --git a/src/pacman/query.c b/src/pacman/query.c index 25a3c5d2..f27c5c29 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -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; -- cgit v1.2.3-70-g09d2