From: Michael Tremer Date: Wed, 24 Mar 2021 16:32:01 +0000 (+0000) Subject: libpakfire: Drop all calls to assert() X-Git-Tag: 0.9.28~1285^2~466 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44df108ed320ba3322c758a74f109b6037bb780a;p=pakfire.git libpakfire: Drop all calls to assert() Although it is nice to check whether the code is passing basic checks, it is not a great idea to just terminate the program. Therefore we cannot use assert(). Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 4de9ff6cc..d8eea262e 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include #include @@ -302,8 +301,6 @@ PAKFIRE_EXPORT unsigned long pakfire_package_get_epoch(PakfirePackage pkg) { if (e) { long int converted = strtol(e, &endptr, 10); - assert(converted > 0); - assert(*endptr == '\0'); epoch = converted; } diff --git a/src/libpakfire/relation.c b/src/libpakfire/relation.c index 2228c8dd2..5a166964f 100644 --- a/src/libpakfire/relation.c +++ b/src/libpakfire/relation.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include @@ -84,8 +83,6 @@ PAKFIRE_EXPORT PakfireRelation pakfire_relation_create(Pakfire pakfire, const ch return NULL; if (evr) { - assert(cmp_type); - Id ievr = pool_str2id(p, evr, 1); int flags = cmptype2relflags(cmp_type); id = pool_rel2id(p, id, ievr, flags, 1); diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index d1ac432a8..40f9478af 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include #include diff --git a/src/libpakfire/selector.c b/src/libpakfire/selector.c index 8c7bc05ee..084cc8bbf 100644 --- a/src/libpakfire/selector.c +++ b/src/libpakfire/selector.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include @@ -159,8 +158,6 @@ PAKFIRE_EXPORT int pakfire_selector_set(PakfireSelector selector, int keyname, i return PAKFIRE_E_SELECTOR; } - assert(filter); - pakfire_selector_replace_filter(filter, keyname, cmp_type, match); return 0; @@ -208,7 +205,8 @@ static int filter_arch2queue(Pakfire pakfire, const PakfireFilter f, Queue* queu if (f == NULL) return 0; - assert(f->cmp_type == PAKFIRE_EQ); + if (f->cmp_type != PAKFIRE_EQ) + return 1; Pool* pool = pakfire_get_solv_pool(pakfire); Id archid = str2archid(pool, f->match); @@ -229,7 +227,8 @@ static int filter_evr2queue(Pakfire pakfire, const PakfireFilter f, Queue* queue if (f == NULL) return 0; - assert(f->cmp_type == PAKFIRE_EQ); + if (f->cmp_type != PAKFIRE_EQ) + return 1; Pool* pool = pakfire_get_solv_pool(pakfire); Id evr = pool_str2id(pool, f->match, 1); diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index f0a00fb85..8bef42d9c 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include @@ -223,9 +222,5 @@ PAKFIRE_EXPORT char* pakfire_solution_to_string(PakfireSolution solution) { if (p > s) *(p-1) = '\0'; - // Make sure that we wrote the string exactly to - // the last character - assert((s + length) == p); - return strdup(s); } diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index 929b0dfff..d3cccc266 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -18,7 +18,6 @@ # # #############################################################################*/ -#include #include #include @@ -218,8 +217,6 @@ PAKFIRE_EXPORT PakfirePackageList pakfire_transaction_get_packages(PakfireTransa } static void pakfire_transaction_add_headline(char** str, size_t width, const char* headline) { - assert(headline); - asprintf(str, "%s%s\n", *str, headline); }