[pacman-dev] [PATCH] conflict.c: compare package pointers directly

Dave Reisner d at falconindy.com
Sat Apr 27 15:11:38 EDT 2013


On Sat, Apr 27, 2013 at 03:07:44PM -0400, Andrew Gregory wrote:
> p1 and p2 both come directly from the upgrade list without being copied
> so they can be compared directly instead of comparing their names.
> 
> Also fix minor style violation.
> 
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---
>  lib/libalpm/conflict.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
> index 18e29a8..465f8b8 100644
> --- a/lib/libalpm/conflict.c
> +++ b/lib/libalpm/conflict.c
> @@ -556,11 +556,11 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
>  
>  			/* Look at all the targets to see if file has changed hands */
>  			for(k = upgrade; k && !resolved_conflict; k = k->next) {
> -				alpm_pkg_t *p2 = k->data;
> -				if(!p2 || strcmp(p1->name, p2->name) == 0) {
> +				alpm_pkg_t *localp2, *p2 = k->data;
> +				if(!p2 || p1 == p2) {

Seems worthy of a comment explaining why we're able to do this so that
we're less likely to break in the future if/when the code changes.

>  					continue;
>  				}
> -				alpm_pkg_t *localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name);
> +				localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name);
>  
>  				/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
>  				_alpm_filelist_resolve(handle, alpm_pkg_get_files(localp2));
> -- 
> 1.8.2.2
> 
> 


More information about the pacman-dev mailing list