[pacman-dev] [PATCH 3/4] query_fileowner: don't append '/' if path is "/"

Andrew Gregory andrew.gregory.8 at gmail.com
Tue Aug 28 00:34:28 EDT 2012


On Mon, 27 Aug 2012 17:24:54 +1000
Allan McRae <allan at archlinux.org> wrote:

> On 12/08/12 07:35, Andrew Gregory wrote:
> > Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> > ---
> >  src/pacman/query.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/pacman/query.c b/src/pacman/query.c
> > index 9afe680..d882e5a 100644
> > --- a/src/pacman/query.c
> > +++ b/src/pacman/query.c
> > @@ -123,8 +123,10 @@ static int query_fileowner(alpm_list_t
> > *targets) }
> >  
> >  	/* append trailing '/' removed by realpath */
> > -	path[rootlen++] = '/';
> > -	path[rootlen] = '\0';
> > +	if(strcmp(path, "/") != 0) {
> 
> Given this is the uncommon case, can we change this to the less
> expensive:
> 
> if(rootlen == 1 && path[0] == '/')
> 
> 

Sure, but we may as well make it more generalized too by just testing
for a trailing '/' with:

if(path[rootlen - 1] != '/')

> > +		path[rootlen++] = '/';
> > +		path[rootlen] = '\0';
> > +	}
> >  
> >  	db_local = alpm_get_localdb(config->handle);
> >  
> > 
> 
> 



More information about the pacman-dev mailing list