]> git.ipfire.org Git - pakfire.git/commitdiff
Use assert() to make the static analyzer happy
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 15 Feb 2025 14:47:05 +0000 (14:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 15 Feb 2025 14:47:05 +0000 (14:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/archive.c
src/pakfire/path.c
src/pakfire/repo.c

index 5df266cd4e9d68c491487993e4c5df838ba56724..148ba7844d0bd2f3face47b4f0bd2521d1f68c8f 100644 (file)
@@ -18,6 +18,7 @@
 #                                                                             #
 #############################################################################*/
 
+#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -605,10 +606,7 @@ static int __pakfire_archive_read_metadata(struct pakfire_archive* archive,
        }
 
        // Make the static analyzer happy which thinks this could be NULL
-       if (!data) {
-               r = -EINVAL;
-               goto ERROR;
-       }
+       assert(data);
 
        // Format >= 6
        if (likely(archive->format >= 6)) {
index 0f5a60e790f15718dae5534cb68391002ac55f4e..e0b1985b6243609d92d282aa3f5a6bff876e141e 100644 (file)
@@ -18,6 +18,7 @@
 #                                                                             #
 #############################################################################*/
 
+#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stddef.h>
@@ -402,8 +403,7 @@ int __pakfire_path_basename(char* buffer, const size_t length, const char* s) {
                goto ERROR;
 
        // Make the static analyzer happy
-       if (!path)
-               goto ERROR;
+       assert(path);
 
        // Drop everything but the last segment
        while (path->num_segments > 1) {
@@ -441,8 +441,7 @@ int __pakfire_path_dirname(char* buffer, const size_t length, const char* s) {
                goto ERROR;
 
        // Make the static analyzer happy
-       if (!path)
-               goto ERROR;
+       assert(path);
 
        // Drop the last segment
        r = pakfire_path_remove_segment(path, path->num_segments - 1);
@@ -477,8 +476,7 @@ int __pakfire_path_relative(char* buffer, const size_t length, const char* __roo
                goto ERROR;
 
        // Make the static analyzer happy
-       if (!root || !path)
-               goto ERROR;
+       assert(root && path);
 
        // Both paths must be absolute
        if (!root->is_absolute || !path->is_absolute) {
@@ -535,8 +533,7 @@ int pakfire_path_is_absolute(const char* s) {
                return r;
 
        // Make the static analyzer happy
-       if (!path)
-               return -EINVAL;
+       assert(path);
 
        // Is this absolute?
        r = path->is_absolute;
@@ -556,8 +553,7 @@ int __pakfire_path_absolute(char* buffer, const size_t length, const char* s) {
                return r;
 
        // Make the static analyzer happy
-       if (!path)
-               return -EINVAL;
+       assert(path);
 
        // Make it absolute
        path->is_absolute = 1;
index b8ff0fdad4a62b236e30fdb6facc0115be7ebc3e..1e7e2be2b5752da62baffad1983305216fc0d3f9 100644 (file)
@@ -18,6 +18,7 @@
 #                                                                             #
 #############################################################################*/
 
+#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <fts.h>
@@ -361,8 +362,7 @@ static int __pakfire_repo_import(struct pakfire_config* config, const char* sect
                goto ERROR;
 
        // Make the static analyzer happy
-       if (!self)
-               goto ERROR;
+       assert(self);
 
        // Enabled
        pakfire_repo_set_enabled(self, pakfire_config_get_bool(config, section, "enabled", 1));
@@ -1478,10 +1478,7 @@ int pakfire_repo_create(struct pakfire_repo** repo,
        }
 
        // Make the static analyzer happy
-       if (!self->appdata) {
-               r = -ENOMEM;
-               goto ERROR;
-       }
+       assert(self->appdata);
 
        // Update the subpriority
        pakfire_repo_update_subpriority(self);