]> git.ipfire.org Git - pakfire.git/commitdiff
arch: Fix any warnings from -fanalyzer
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Jul 2021 15:18:43 +0000 (15:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Jul 2021 15:18:43 +0000 (15:18 +0000)
Add checks for potential NULL inputs where non-NULL values are expected.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c

index 689adc99b1cb8928896bfaaf54aba5ee75acf774..e3a5a20ae5ef96d849b3811c68dce886ea024e70 100644 (file)
@@ -211,6 +211,11 @@ PAKFIRE_EXPORT const char* pakfire_arch_native() {
 }
 
 int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) {
+       if (!name || !compatible_arch) {
+               errno = EINVAL;
+               return 1;
+       }
+
        // Every architecture is compatible with itself
        if (strcmp(name, compatible_arch) == 0)
                return 1;
@@ -228,6 +233,11 @@ int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) {
 }
 
 static int pakfire_arch_supported_by_host(const char* name) {
+       if (!name) {
+               errno = EINVAL;
+               return 1;
+       }
+
        const char* native_arch = pakfire_arch_native();
 
        // Check if those two architectures are compatible
@@ -285,6 +295,11 @@ static char* find_interpreter(const char* path, const char* magic) {
 }
 
 char* pakfire_arch_find_interpreter(const char* name) {
+       if (!name) {
+               errno = EINVAL;
+               return NULL;
+       }
+
        // If the host supports this architecture natively,
        // we do not need to search for the interpreter
        if (pakfire_arch_supported_by_host(name))