From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35077 invoked by alias); 2 May 2017 21:59:32 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 35064 invoked by uid 89); 2 May 2017 21:59:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=Hx-languages-length:2477 X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 21:59:29 +0000 Received: from stream.wildebeest.org (deer0x01.wildebeest.org [172.31.17.131]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 93DD1302755A; Tue, 2 May 2017 23:59:28 +0200 (CEST) Received: by stream.wildebeest.org (Postfix, from userid 1000) id 1BEE9FF8A1; Tue, 2 May 2017 23:28:53 +0200 (CEST) Date: Wed, 03 May 2017 10:50:00 -0000 From: Mark Wielaard To: Ulf Hermann Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] Don't look for kernel version if not running on linux Message-ID: <20170502212852.GG3321@stream> References: <20170427180231.GB2061@stream> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Md/poaVZ8hnGTzuv" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00136.txt.bz2 --Md/poaVZ8hnGTzuv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 804 On Tue, May 02, 2017 at 12:17:24PM +0200, Ulf Hermann wrote: > > You can get uname() on Windows through gnulib, but at the cost at > > linking to additional windows DLLs. It calls gethostname and for that > > we need to link against ws2_32.dll. That's an unreasonable dependency > > for getting something we cannot use anyway. I suggest we just set > > errno to ENOTSUP then. > > I should clarify this a bit. We only use uname() to obtain the kernel > version and we only use the kernel version to search for directories > containing kernel modules. The only operating system where this makes sense > is linux as we cannot handle anything but linux kernel modules there. > Therefore there is no point in retrieving the kernel version on any other > OS. Agreed. So committed as attached. Thanks, Mark --Md/poaVZ8hnGTzuv Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Don-t-look-for-kernel-version-if-not-running-on-linu.patch" Content-length: 1670 >From e88787f9cd2af5be00aa6f53320cf85f7c08f1f2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 20 Apr 2017 16:08:48 +0200 Subject: [PATCH] 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 --- libdwfl/ChangeLog | 6 ++++++ libdwfl/linux-kernel-modules.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 1fc9da6..859b2ff 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,4 +1,10 @@ 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. * argp-std.c: Include config.h. diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 893110a..9d0fef2 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 -- 2.9.3 --Md/poaVZ8hnGTzuv--