From nobody Wed Nov 24 17:39:11 2021 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 82392189A380; Wed, 24 Nov 2021 17:39:18 +0000 (UTC) (envelope-from cmt@burggraben.net) Received: from smtp.burggraben.net (smtp.burggraben.net [88.198.69.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.burggraben.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzpCp297Fz4ttj; Wed, 24 Nov 2021 17:39:18 +0000 (UTC) (envelope-from cmt@burggraben.net) Received: from elch.exwg.net (elch.exwg.net [IPv6:2001:470:7120:1:127b:44ff:fe4f:148d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "elch.exwg.net", Issuer "R3" (not verified)) by smtp.burggraben.net (Postfix) with ESMTPS id 88164C00318; Wed, 24 Nov 2021 18:39:11 +0100 (CET) Received: by elch.exwg.net (Postfix, from userid 1000) id 0CF3D3AB04; Wed, 24 Nov 2021 18:39:11 +0100 (CET) Date: Wed, 24 Nov 2021 18:39:11 +0100 From: Christoph Moench-Tegeder To: Dmitry Marakasov Cc: ports-committers@freebsd.org, dev-commits-ports-all@freebsd.org, dev-commits-ports-main@freebsd.org Subject: Re: git: 1cc5f5584961 - main - graphics/geeqie: don't try to get number of cpu cores from /proc Message-ID: References: <202111241719.1AOHJQui087071@gitrepo.freebsd.org> List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <202111241719.1AOHJQui087071@gitrepo.freebsd.org> User-Agent: Mutt/2.1.3 (2021-09-10) X-Rspamd-Queue-Id: 4HzpCp297Fz4ttj X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N ## Dmitry Marakasov (amdmi3@FreeBSD.org): > graphics/geeqie: don't try to get number of cpu cores from /proc Sometimes it's very obvious that nobody reads APUE anymore. How about this? It's POSIX and not more wrong as the original. (And 5 lines, two of which are blank). --- src/misc.c.orig 2021-11-24 18:28:48.794664000 +0100 +++ src/misc.c 2021-11-24 18:31:07.753874000 +0100 @@ -378,29 +378,11 @@ gint get_cpu_cores(void) { - FILE *cpuinfo = fopen("/proc/cpuinfo", "rb"); - char *arg = 0; - size_t size = 0; - int cores = 1; - gchar *siblings_line; - gchar *siblings_str; + long cores; - while(getline(&arg, &size, cpuinfo) != -1) - { - siblings_line = g_strrstr(arg, "siblings"); - if (siblings_line) - { - siblings_str = g_strrstr(siblings_line, ":"); - if (siblings_str) - { - cores = g_ascii_strtoll(siblings_str + 1, NULL, 0); - } - } - } - free(arg); - fclose(cpuinfo); + cores = sysconf(_SC_NPROCESSORS_ONLN); - return cores; + return cores > 0 ? (gint) cores : 1; } void tree_path_free_wrapper(void *data, void *useradata) Regards, Christoph -- Spare Space