[pacman-dev] [PATCH] query.c: simplify is_foreign

Allan McRae allan at archlinux.org
Sat Dec 1 02:02:48 EST 2012


On 25/11/12 04:16, Dave Reisner wrote:
> On Sat, Nov 24, 2012 at 01:13:45PM -0500, Andrew Gregory wrote:
>> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
>> ---
>>  src/pacman/query.c | 14 ++++----------
>>  1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/pacman/query.c b/src/pacman/query.c
>> index b6913f0..7c4aebd 100644
>> --- a/src/pacman/query.c
>> +++ b/src/pacman/query.c
>> @@ -367,19 +367,13 @@ static int is_foreign(alpm_pkg_t *pkg)
>>  	alpm_list_t *j;
>>  	alpm_list_t *sync_dbs = alpm_get_syncdbs(config->handle);
>>  
>> -	int match = 0;
>>  	for(j = sync_dbs; j; j = alpm_list_next(j)) {
>> -		alpm_db_t *db = j->data;
>> -		alpm_pkg_t *findpkg = alpm_db_get_pkg(db, pkgname);
>> -		if(findpkg) {
>> -			match = 1;
>> -			break;
>> +		alpm_db_t* db = j->data;
>> +		if(alpm_db_get_pkg(db, pkgname)) {
> 
> You could go one step further here and just replace *db with j->data.
> There's no error in passing a void* to alpm_db_get_pkg().
> 

That would also fix the introduced braking of coding style in the
pointer declaration...

>> +			return 0;
>>  		}
>>  	}
>> -	if(match == 0) {
>> -		return 1;
>> -	}
>> -	return 0;
>> +	return 1;
>>  }
>>  
>>  static int is_unrequired(alpm_pkg_t *pkg)
>> -- 
>> 1.8.0
>>
>>
> 
> 
> 



More information about the pacman-dev mailing list