[pacman-dev] [PATCH] Rename mount point struct
Rename alpm_mountpoint_t to pmmountpoint_t to keep naming consistent with every other struct we have. Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/diskspace.c | 26 +++++++++++++------------- lib/libalpm/diskspace.h | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 51aa47f..8824654 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -53,8 +53,8 @@ static int mount_point_cmp(const void *p1, const void *p2) { - const alpm_mountpoint_t *mp1 = p1; - const alpm_mountpoint_t *mp2 = p2; + const pmmountpoint_t *mp1 = p1; + const pmmountpoint_t *mp2 = p2; /* the negation will sort all mountpoints before their parent */ return -strcmp(mp1->mount_dir, mp2->mount_dir); } @@ -62,7 +62,7 @@ static int mount_point_cmp(const void *p1, const void *p2) static alpm_list_t *mount_point_list(pmhandle_t *handle) { alpm_list_t *mount_points = NULL, *ptr; - alpm_mountpoint_t *mp; + pmmountpoint_t *mp; #if defined HAVE_GETMNTENT struct mntent *mnt; @@ -87,7 +87,7 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) continue; } - CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, PM_ERR_MEMORY, NULL)); + CALLOC(mp, 1, sizeof(pmmountpoint_t), RET_ERR(handle, PM_ERR_MEMORY, NULL)); mp->mount_dir = strdup(mnt->mnt_dir); mp->mount_dir_len = strlen(mp->mount_dir); memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs)); @@ -108,7 +108,7 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) } for(; entries-- > 0; fsp++) { - CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL)); + CALLOC(mp, 1, sizeof(pmmountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL)); mp->mount_dir = strdup(fsp->f_mntonname); mp->mount_dir_len = strlen(mp->mount_dir); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE)); @@ -131,13 +131,13 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) return mount_points; } -static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points, +static pmmountpoint_t *match_mount_point(const alpm_list_t *mount_points, const char *real_path) { const alpm_list_t *mp; for(mp = mount_points; mp != NULL; mp = mp->next) { - alpm_mountpoint_t *data = mp->data; + pmmountpoint_t *data = mp->data; if(strncmp(data->mount_dir, real_path, data->mount_dir_len) == 0) { return data; @@ -155,7 +155,7 @@ static int calculate_removed_size(pmhandle_t *handle, alpm_list_t *files = alpm_pkg_get_files(pkg); for(file = files; file; file = file->next) { - alpm_mountpoint_t *mp; + pmmountpoint_t *mp; struct stat st; char path[PATH_MAX]; const char *filename = file->data; @@ -209,7 +209,7 @@ static int calculate_installed_size(pmhandle_t *handle, } while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { - alpm_mountpoint_t *mp; + pmmountpoint_t *mp; const char *filename; mode_t mode; char path[PATH_MAX]; @@ -260,7 +260,7 @@ cleanup: int _alpm_check_diskspace(pmhandle_t *handle) { alpm_list_t *mount_points, *i; - alpm_mountpoint_t *root_mp; + pmmountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; int error = 0; alpm_list_t *targ; @@ -308,7 +308,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) calculate_installed_size(handle, mount_points, pkg); for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; if(data->blocks_needed > data->max_blocks_needed) { data->max_blocks_needed = data->blocks_needed; } @@ -319,7 +319,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) numtargs, current); for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; if(data->used && data->read_only) { _alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"), data->mount_dir); @@ -344,7 +344,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) } for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; FREE(data->mount_dir); } FREELIST(mount_points); diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h index 28aca7e..d2aa8a8 100644 --- a/lib/libalpm/diskspace.h +++ b/lib/libalpm/diskspace.h @@ -34,7 +34,7 @@ enum mount_used_level { USED_INSTALL = (1 << 1), }; -typedef struct __alpm_mountpoint_t { +typedef struct __pmmountpoint_t { /* mount point information */ char *mount_dir; size_t mount_dir_len; @@ -44,7 +44,7 @@ typedef struct __alpm_mountpoint_t { enum mount_used_level used; int read_only; FSSTATSTYPE fsp; -} alpm_mountpoint_t; +} pmmountpoint_t; int _alpm_check_diskspace(pmhandle_t *handle); -- 1.7.6
On Mon, Jun 27, 2011 at 9:26 PM, Allan McRae <allan@archlinux.org> wrote:
Rename alpm_mountpoint_t to pmmountpoint_t to keep naming consistent with every other struct we have.
What if I said "f*** it, it's 4.0, we should fix them all to be alpm_ like they should have always been"? I'm tempted to actually go the other way- this one doesnt matter so much since it is internal to the library, but we are very inconsistent with exposing PM_, pmxxx_t, etc. when all our functions are rightly named alpm_*(). Thoughts?
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/diskspace.c | 26 +++++++++++++------------- lib/libalpm/diskspace.h | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 51aa47f..8824654 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -53,8 +53,8 @@
static int mount_point_cmp(const void *p1, const void *p2) { - const alpm_mountpoint_t *mp1 = p1; - const alpm_mountpoint_t *mp2 = p2; + const pmmountpoint_t *mp1 = p1; + const pmmountpoint_t *mp2 = p2; /* the negation will sort all mountpoints before their parent */ return -strcmp(mp1->mount_dir, mp2->mount_dir); } @@ -62,7 +62,7 @@ static int mount_point_cmp(const void *p1, const void *p2) static alpm_list_t *mount_point_list(pmhandle_t *handle) { alpm_list_t *mount_points = NULL, *ptr; - alpm_mountpoint_t *mp; + pmmountpoint_t *mp;
#if defined HAVE_GETMNTENT struct mntent *mnt; @@ -87,7 +87,7 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) continue; }
- CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, PM_ERR_MEMORY, NULL)); + CALLOC(mp, 1, sizeof(pmmountpoint_t), RET_ERR(handle, PM_ERR_MEMORY, NULL)); mp->mount_dir = strdup(mnt->mnt_dir); mp->mount_dir_len = strlen(mp->mount_dir); memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs)); @@ -108,7 +108,7 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) }
for(; entries-- > 0; fsp++) { - CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL)); + CALLOC(mp, 1, sizeof(pmmountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL)); mp->mount_dir = strdup(fsp->f_mntonname); mp->mount_dir_len = strlen(mp->mount_dir); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE)); @@ -131,13 +131,13 @@ static alpm_list_t *mount_point_list(pmhandle_t *handle) return mount_points; }
-static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points, +static pmmountpoint_t *match_mount_point(const alpm_list_t *mount_points, const char *real_path) { const alpm_list_t *mp;
for(mp = mount_points; mp != NULL; mp = mp->next) { - alpm_mountpoint_t *data = mp->data; + pmmountpoint_t *data = mp->data;
if(strncmp(data->mount_dir, real_path, data->mount_dir_len) == 0) { return data; @@ -155,7 +155,7 @@ static int calculate_removed_size(pmhandle_t *handle,
alpm_list_t *files = alpm_pkg_get_files(pkg); for(file = files; file; file = file->next) { - alpm_mountpoint_t *mp; + pmmountpoint_t *mp; struct stat st; char path[PATH_MAX]; const char *filename = file->data; @@ -209,7 +209,7 @@ static int calculate_installed_size(pmhandle_t *handle, }
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { - alpm_mountpoint_t *mp; + pmmountpoint_t *mp; const char *filename; mode_t mode; char path[PATH_MAX]; @@ -260,7 +260,7 @@ cleanup: int _alpm_check_diskspace(pmhandle_t *handle) { alpm_list_t *mount_points, *i; - alpm_mountpoint_t *root_mp; + pmmountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; int error = 0; alpm_list_t *targ; @@ -308,7 +308,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) calculate_installed_size(handle, mount_points, pkg);
for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; if(data->blocks_needed > data->max_blocks_needed) { data->max_blocks_needed = data->blocks_needed; } @@ -319,7 +319,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) numtargs, current);
for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; if(data->used && data->read_only) { _alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"), data->mount_dir); @@ -344,7 +344,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) }
for(i = mount_points; i; i = alpm_list_next(i)) { - alpm_mountpoint_t *data = i->data; + pmmountpoint_t *data = i->data; FREE(data->mount_dir); } FREELIST(mount_points); diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h index 28aca7e..d2aa8a8 100644 --- a/lib/libalpm/diskspace.h +++ b/lib/libalpm/diskspace.h @@ -34,7 +34,7 @@ enum mount_used_level { USED_INSTALL = (1 << 1), };
-typedef struct __alpm_mountpoint_t { +typedef struct __pmmountpoint_t { /* mount point information */ char *mount_dir; size_t mount_dir_len; @@ -44,7 +44,7 @@ typedef struct __alpm_mountpoint_t { enum mount_used_level used; int read_only; FSSTATSTYPE fsp; -} alpm_mountpoint_t; +} pmmountpoint_t;
int _alpm_check_diskspace(pmhandle_t *handle);
-- 1.7.6
On 28/06/11 12:26, Dan McGee wrote:
On Mon, Jun 27, 2011 at 9:26 PM, Allan McRae<allan@archlinux.org> wrote:
Rename alpm_mountpoint_t to pmmountpoint_t to keep naming consistent with every other struct we have.
What if I said "f*** it, it's 4.0, we should fix them all to be alpm_ like they should have always been"? I'm tempted to actually go the other way- this one doesnt matter so much since it is internal to the library, but we are very inconsistent with exposing PM_, pmxxx_t, etc. when all our functions are rightly named alpm_*().
Thoughts?
My thoughts are that I am glad I stopped writing my GTK3 libalpm frontend when I realised what was happening to the API! :D I am actually quite comfortable with the distinction that alpm_* is a function and pm*_t is a type. But saying that, converting the pmxxx_t to alpm_xxx_t does seem an overall more consistent approach. Our list type is already prefixed alpm_ and now we have exposed a lot more of those structs it is probably worth changing them. And now is the best time to do this. So lets say I am more in favor of doing this than not (yay for committed answers!). I would be quite happy to prepare the patchset to do it. Allan
participants (2)
-
Allan McRae
-
Dan McGee