From: Michael Tremer Date: Fri, 2 Jul 2021 15:18:43 +0000 (+0000) Subject: arch: Fix any warnings from -fanalyzer X-Git-Tag: 0.9.28~1132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cede6a7a53afe1e27d52e4d086e60a8ff9e11c8;p=pakfire.git arch: Fix any warnings from -fanalyzer Add checks for potential NULL inputs where non-NULL values are expected. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/arch.c b/src/libpakfire/arch.c index 689adc99b..e3a5a20ae 100644 --- a/src/libpakfire/arch.c +++ b/src/libpakfire/arch.c @@ -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))