FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-24-2011, 11:20 PM
Allan McRae
 
Default Remove two alpm_list_count usages

We have just looped through the list of files, so might as well get
the count as we go.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
lib/libalpm/remove.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index b6a4c71..cc6daea 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -287,7 +287,7 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
{
alpm_list_t *skip_remove, *b;
alpm_list_t *newfiles, *lp;
- size_t filenum;
+ size_t filenum=0;
alpm_list_t *files = alpm_pkg_get_files(oldpkg);
const char *pkgname = alpm_pkg_get_name(oldpkg);

@@ -323,9 +323,9 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
"not removing package '%s', can't remove all files
", pkgname);
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
}
+ filenum++;
}

- filenum = alpm_list_count(files);
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files
", (unsigned long)filenum);

/* iterate through the list backwards, unlinking files */
@@ -391,7 +391,7 @@ int _alpm_remove_packages(pmhandle_t *handle)
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
alpm_list_t *files = alpm_pkg_get_files(info);
alpm_list_t *newfiles;
- size_t filenum;
+ size_t filenum=0;

for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(handle, lp->data, NULL)) {
@@ -399,9 +399,9 @@ int _alpm_remove_packages(pmhandle_t *handle)
pkgname);
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
}
+ filenum++;
}

- filenum = alpm_list_count(files);
_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files
", (unsigned long)filenum);

/* init progress bar */
--
1.7.5.4
 
Old 06-27-2011, 02:17 PM
Dan McGee
 
Default Remove two alpm_list_count usages

On Fri, Jun 24, 2011 at 6:20 PM, Allan McRae <allan@archlinux.org> wrote:
> We have just looped through the list of files, so might as well get
> the count as we go.

Looks good, but please use spaces when initializing variables as this
isn't bash .

> Signed-off-by: Allan McRae <allan@archlinux.org>
> ---
> *lib/libalpm/remove.c | * *8 ++++----
> *1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
> index b6a4c71..cc6daea 100644
> --- a/lib/libalpm/remove.c
> +++ b/lib/libalpm/remove.c
> @@ -287,7 +287,7 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
> *{
> * * * *alpm_list_t *skip_remove, *b;
> * * * *alpm_list_t *newfiles, *lp;
> - * * * size_t filenum;
> + * * * size_t filenum=0;
> * * * *alpm_list_t *files = alpm_pkg_get_files(oldpkg);
> * * * *const char *pkgname = alpm_pkg_get_name(oldpkg);
>
> @@ -323,9 +323,9 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
> * * * * * * * * * * * * * * * * * * * *"not removing package '%s', can't remove all files
", pkgname);
> * * * * * * * * * * * *RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
> * * * * * * * *}
> + * * * * * * * filenum++;
> * * * *}
>
> - * * * filenum = alpm_list_count(files);
> * * * *_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files
", (unsigned long)filenum);
>
> * * * */* iterate through the list backwards, unlinking files */
> @@ -391,7 +391,7 @@ int _alpm_remove_packages(pmhandle_t *handle)
> * * * * * * * *if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
> * * * * * * * * * * * *alpm_list_t *files = alpm_pkg_get_files(info);
> * * * * * * * * * * * *alpm_list_t *newfiles;
> - * * * * * * * * * * * size_t filenum;
> + * * * * * * * * * * * size_t filenum=0;
>
> * * * * * * * * * * * *for(lp = files; lp; lp = lp->next) {
> * * * * * * * * * * * * * * * *if(!can_remove_file(handle, lp->data, NULL)) {
> @@ -399,9 +399,9 @@ int _alpm_remove_packages(pmhandle_t *handle)
> * * * * * * * * * * * * * * * * * * * * * * * * *pkgname);
> * * * * * * * * * * * * * * * * * * * *RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
> * * * * * * * * * * * * * * * *}
> + * * * * * * * * * * * * * * * filenum++;
> * * * * * * * * * * * *}
>
> - * * * * * * * * * * * filenum = alpm_list_count(files);
> * * * * * * * * * * * *_alpm_log(handle, PM_LOG_DEBUG, "removing %ld files
", (unsigned long)filenum);
>
> * * * * * * * * * * * */* init progress bar */
> --
> 1.7.5.4
>
>
>
 

Thread Tools




All times are GMT. The time now is 10:29 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org