From: Ulf Hermann Date: Thu, 20 Apr 2017 14:08:48 +0000 (+0200) Subject: Don't look for kernel version if not running on linux X-Git-Tag: elfutils-0.169~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e88787f9cd2af5be00aa6f53320cf85f7c08f1f2;p=thirdparty%2Felfutils.git Don't look for kernel version if not running on linux We don't want to use it, even if it exists. Signed-off-by: Ulf Hermann Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 1fc9da69d..859b2ff56 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2017-04-20 Ulf Hermann + Mark Wielaard + + * linux-kernel-modules.c: Always return NULL from kernel_release() on + non-linux systems and set errno to ENOTSUP. + 2017-04-20 Ulf Hermann * libdwflP.h: Don't include config.h. diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 893110ae8..9d0fef2cf 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -156,11 +156,18 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) static inline const char * kernel_release (void) { +#ifdef __linux__ /* Cache the `uname -r` string we'll use. */ static struct utsname utsname; if (utsname.release[0] == '\0' && uname (&utsname) != 0) return NULL; return utsname.release; +#else + /* Used for finding the running linux kernel, which isn't supported + on non-linux kernel systems. */ + errno = ENOTSUP; + return NULL; +#endif } static int