]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Drop all calls to assert()
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 24 Mar 2021 16:32:01 +0000 (16:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 24 Mar 2021 16:32:01 +0000 (16:32 +0000)
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 <michael.tremer@ipfire.org>
src/libpakfire/package.c
src/libpakfire/relation.c
src/libpakfire/repo.c
src/libpakfire/selector.c
src/libpakfire/solution.c
src/libpakfire/transaction.c

index 4de9ff6cc6a445f47f3e22ffcb446362d21fb6d9..d8eea262ec21b36b1476d00477367e662498ecc1 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <linux/limits.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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;
        }
 
index 2228c8dd25f4f6746f92ac0dbebda1fbc69e67c3..5a166964f90fee9953861c24eefd070d4351b165 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include <solv/pooltypes.h>
@@ -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);
index d1ac432a81586db5be6bb703917bde2dcb9dad0b..40f9478afa7620c47d5c8f229a152cea2089999b 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <errno.h>
 #include <fts.h>
 #include <linux/limits.h>
index 8c7bc05ee08a5478fe7dc6a6a95b70fe74a39ba1..084cc8bbf264c9f9e6a195b92c03ccbe33558c4b 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include <solv/pool.h>
@@ -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);
index f0a00fb85b69bdcedf17e7df86e99a76802962f9..8bef42d9c98b8950209af17563f1c8d447dac256 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include <solv/policy.h>
@@ -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);
 }
index 929b0dfff15e588994c547e0c3a3b437c0ea8bd3..d3cccc266bbdd919111f5144a38e1a8a88cd5805 100644 (file)
@@ -18,7 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#include <assert.h>
 #include <errno.h>
 #include <stdlib.h>
 
@@ -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);
 }