[pacman-dev] [PATCH 2/2] diskspace style cleanups and small fixes

Allan McRae allan at archlinux.org
Wed Nov 17 07:08:28 CET 2010


On 17/11/10 12:12, Dan McGee wrote:
> * Use our normal return() function syntax
> * Rework a few things to reduce number of casts
> * Fix void function argument declaration
> * Add missing gettext _() call
> * Remove need for seperate malloc() of statvfs/statfs structure
> * Unify argument order of static functions- mountpoints now always
>    passed first
> * Count all files that start with '.' in a package against the DB
> * Rename db to db_local in check_diskspace to clarify some code
> * Fix some line wrapping to respect 80 characters
>
> Signed-off-by: Dan McGee<dan at archlinux.org>

(after minor fix below)
Signed-off-by: Allan

> ---
>   lib/libalpm/diskspace.c |  101 ++++++++++++++++++++++++----------------------
>   lib/libalpm/diskspace.h |    4 +-
>   2 files changed, 55 insertions(+), 50 deletions(-)
>
> diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
> index ad6ceba..a96228a 100644
> --- a/lib/libalpm/diskspace.c
> +++ b/lib/libalpm/diskspace.c
...
> @@ -70,20 +72,19 @@ static alpm_list_t *mount_point_list()
>   	fp = setmntent(MOUNTED, "r");
>
>   	if (fp == NULL) {
> -		return NULL;
> +		return(NULL);
>   	}
>
> -	while((mnt = getmntent (fp))) {
> +	while((mnt = getmntent(fp))) {
>   		if(statvfs(mnt->mnt_dir,&fsp) != 0) {
> -			_alpm_log(PM_LOG_WARNING, "could not get filesystem information for %s\n", mnt->mnt_dir);
> +			_alpm_log(PM_LOG_WARNING,
> +					_("could not get filesystem information for %s\n"), mnt->mnt_dir);
>   			continue;
>   		}
>
>   		MALLOC(mp, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL));
>   		mp->mount_dir = strdup(mnt->mnt_dir);
> -
> -		MALLOC(mp->fsp, sizeof(FSSTATSTYPE), RET_ERR(PM_ERR_MEMORY, NULL));
> -		memcpy((void *)(mp->fsp), (void *)(&fsp), sizeof(FSSTATSTYPE));
> +		memcpy(&(mp->fsp),&fsp, sizeof(FSSTATSTYPE));
>
>   		mp->blocks_needed = 0;
>   		mp->max_blocks_needed = 0;
> @@ -106,9 +107,7 @@ static alpm_list_t *mount_point_list()
>   	for(; entries-->  0; fsp++) {
>   		MALLOC(mp, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL));
>   		mp->mount_dir = strdup(fsp->f_mntonname);
> -
> -		MALLOC(mp->fsp, sizeof(FSSTATSTYPE), RET_ERR(PM_ERR_MEMORY, NULL));
> -		memcpy((void *)(mp->fsp), (void *)fsp, sizeof(FSSTATSTYPE));
> +		memcpy(&(mp->fsp),&fsp, sizeof(FSSTATSTYPE));

fsp is a pointer in the getmntinfo code path so...
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));

Allan


More information about the pacman-dev mailing list