Commit b7c983a2 authored by Bernhard Link's avatar Bernhard Link

[refactor] upgradelist: use more package_getversion

parent 108d8430
...@@ -93,38 +93,38 @@ static void package_data_free(/*@only@*/struct package_data *data){ ...@@ -93,38 +93,38 @@ static void package_data_free(/*@only@*/struct package_data *data){
* It is called once for every package we already have in this target. * It is called once for every package we already have in this target.
* upgrade->list points to the first in the sorted list, * upgrade->list points to the first in the sorted list,
* upgrade->last to the last one inserted */ * upgrade->last to the last one inserted */
static retvalue save_package_version(struct upgradelist *upgrade, const char *packagename, const char *chunk) { static retvalue save_package_version(struct upgradelist *upgrade, struct package *pkg) {
char *version;
retvalue r; retvalue r;
struct package_data *package; struct package_data *package;
r = upgrade->target->getversion(chunk, &version); r = package_getversion(pkg);
if (RET_WAS_ERROR(r)) if (RET_WAS_ERROR(r))
return r; return r;
package = zNEW(struct package_data); package = zNEW(struct package_data);
if (FAILEDTOALLOC(package)) { if (FAILEDTOALLOC(package))
free(version);
return RET_ERROR_OOM; return RET_ERROR_OOM;
}
package->privdata = NULL; package->privdata = NULL;
package->name = strdup(packagename); package->name = strdup(pkg->name);
if (FAILEDTOALLOC(package->name)) { if (FAILEDTOALLOC(package->name)) {
free(package); free(package);
free(version);
return RET_ERROR_OOM; return RET_ERROR_OOM;
} }
package->version_in_use = version; package->version_in_use = package_dupversion(pkg);
version = NULL; // just to be sure... if (FAILEDTOALLOC(package->version_in_use)) {
free(package->name);
free(package);
return RET_ERROR_OOM;
}
package->version = package->version_in_use; package->version = package->version_in_use;
if (upgrade->list == NULL) { if (upgrade->list == NULL) {
/* first chunk to add: */ /* first package to add: */
upgrade->list = package; upgrade->list = package;
upgrade->last = package; upgrade->last = package;
} else { } else {
if (strcmp(packagename, upgrade->last->name) > 0) { if (strcmp(pkg->name, upgrade->last->name) > 0) {
upgrade->last->next = package; upgrade->last->next = package;
upgrade->last = package; upgrade->last = package;
} else { } else {
...@@ -159,9 +159,7 @@ retvalue upgradelist_initialize(struct upgradelist **ul, struct target *t) { ...@@ -159,9 +159,7 @@ retvalue upgradelist_initialize(struct upgradelist **ul, struct target *t) {
return r; return r;
} }
while (package_next(&iterator)) { while (package_next(&iterator)) {
r2 = save_package_version(upgrade, r2 = save_package_version(upgrade, &iterator.current);
iterator.current.name,
iterator.current.control);
RET_UPDATE(r, r2); RET_UPDATE(r, r2);
if (RET_WAS_ERROR(r2)) if (RET_WAS_ERROR(r2))
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment