From 7be853e63785276338a4c4d9e5be084f24114bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Sat, 5 Jun 2010 12:06:41 +0300 Subject: all: rework how arrays work Instead of having a null pointer, use a dummy array which just says the array is empty. This helps in multiple places of the code which would otherwise need explicitly need to check first if the array exists. This has been cause of multiple seg.faults in the past as the array check is easily omitted. This also removes (or fixes) all existing checks accordingly. --- src/fetch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/fetch.c') diff --git a/src/fetch.c b/src/fetch.c index 67b3322..dc9bff2 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -205,7 +205,7 @@ static int fetch_main(void *ctx, struct apk_database *db, int argc, char **argv) } apk_state_unref(state); - } else if (dep.name->pkgs != NULL) { + } else { struct apk_package *pkg = NULL; for (j = 0; j < dep.name->pkgs->num; j++) @@ -215,13 +215,15 @@ static int fetch_main(void *ctx, struct apk_database *db, int argc, char **argv) == APK_VERSION_GREATER) pkg = dep.name->pkgs->item[j]; + if (pkg == NULL) { + apk_message("Unable to get '%s'", dep.name->name); + r = -1; + break; + } + r = fetch_package(fctx, db, pkg); if (r != 0) goto err; - } else { - apk_message("Unable to get '%s'", dep.name->name); - r = -1; - break; } } -- cgit v1.2.3