mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Ensure fileconflict value is actually a string
When we switched to a file object and not just a simple string, we missed an update along the way here in target-target conflicts. This patch looks large, but it really comes down to one errant (char *) cast before that has been reworked to explicitly point to the alpm_file_t object. The rest is simply code cleanup. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
d1fc3aec4c
commit
80b0f27125
@ -276,30 +276,29 @@ static alpm_list_t *filelist_operation(alpm_filelist_t *filesA,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds alpm_fileconflict_t to a conflicts list. Pass the conflicts list, type
|
/* Adds alpm_fileconflict_t to a conflicts list. Pass the conflicts list, the
|
||||||
* (either ALPM_FILECONFLICT_TARGET or ALPM_FILECONFLICT_FILESYSTEM), a file
|
* conflicting file path, and either two packages or one package and NULL.
|
||||||
* string, and either two package names or one package name and NULL. This is
|
|
||||||
* a wrapper for former functionality that was done inline.
|
|
||||||
*/
|
*/
|
||||||
static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
|
static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
|
||||||
alpm_list_t *conflicts, alpm_fileconflicttype_t type, const char *filestr,
|
alpm_list_t *conflicts, const char *filestr,
|
||||||
const char *name1, const char *name2)
|
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
|
||||||
{
|
{
|
||||||
alpm_fileconflict_t *conflict;
|
alpm_fileconflict_t *conflict;
|
||||||
MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
|
MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
|
||||||
|
|
||||||
conflict->type = type;
|
STRDUP(conflict->target, pkg1->name, goto error);
|
||||||
STRDUP(conflict->target, name1, goto error);
|
|
||||||
STRDUP(conflict->file, filestr, goto error);
|
STRDUP(conflict->file, filestr, goto error);
|
||||||
if(name2) {
|
if(pkg2) {
|
||||||
STRDUP(conflict->ctarget, name2, goto error);
|
conflict->type = ALPM_FILECONFLICT_TARGET;
|
||||||
|
STRDUP(conflict->ctarget, pkg2->name, goto error);
|
||||||
} else {
|
} else {
|
||||||
|
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
|
||||||
STRDUP(conflict->ctarget, "", goto error);
|
STRDUP(conflict->ctarget, "", goto error);
|
||||||
}
|
}
|
||||||
|
|
||||||
conflicts = alpm_list_add(conflicts, conflict);
|
conflicts = alpm_list_add(conflicts, conflict);
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
|
||||||
filestr, name1, name2 ? name2 : "(filesystem)");
|
filestr, pkg1->name, pkg2 ? pkg2->name : "(filesystem)");
|
||||||
|
|
||||||
return conflicts;
|
return conflicts;
|
||||||
|
|
||||||
@ -416,9 +415,9 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
|||||||
alpm_list_t *k;
|
alpm_list_t *k;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
for(k = common_files; k; k = k->next) {
|
for(k = common_files; k; k = k->next) {
|
||||||
snprintf(path, PATH_MAX, "%s%s", handle->root, (char *)k->data);
|
alpm_file_t *file = k->data;
|
||||||
conflicts = add_fileconflict(handle, conflicts,
|
snprintf(path, PATH_MAX, "%s%s", handle->root, file->name);
|
||||||
ALPM_FILECONFLICT_TARGET, path, p1->name, p2->name);
|
conflicts = add_fileconflict(handle, conflicts, path, p1, p2);
|
||||||
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
||||||
FREELIST(conflicts);
|
FREELIST(conflicts);
|
||||||
FREELIST(common_files);
|
FREELIST(common_files);
|
||||||
@ -567,8 +566,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!resolved_conflict) {
|
if(!resolved_conflict) {
|
||||||
conflicts = add_fileconflict(handle, conflicts,
|
conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
|
||||||
ALPM_FILECONFLICT_FILESYSTEM, path, p1->name, NULL);
|
|
||||||
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
||||||
FREELIST(conflicts);
|
FREELIST(conflicts);
|
||||||
if(dbpkg) {
|
if(dbpkg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user