From nobody Sun Feb 8 13:57:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571315979; cv=none; d=zoho.com; s=zohoarc; b=mDQjRjX9YSF0q6MagmXKOj1ItWVWN0LEHtmRiA7zovwF+7jvQogKpCILV+42XMwPDvipXIf5IglzRTiyCI3jaWYS7v8ThgjohCEb0AqXTeKu44oumWrxpQpT0+vesiotUlXCp8R50XaE2OprGuQJctir49IQfb962gLJwwdFCb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571315979; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=k4bv22+6vrvmE7LRTGqHXn7bDo6l5gcFE05UN7e9g8Y=; b=d2P/IC71y2gdblhNj28YNQtbtgunPL1EyVGlZ+tstUaTwHnCPJP3UYV9bN+l6LdtAcIF9esUZJIJTRgLYp6Zk2mQcxuARj9CfJi1DExbVuHvHmTao1ChePToeglk8nXTEFk3gaH9lx6S1PftI4FRu9ZCicoDaNbK6vVDYCfzJxM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571315979140540.0100261505123; Thu, 17 Oct 2019 05:39:39 -0700 (PDT) Received: from localhost ([::1]:46154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL545-00021X-Rp for importer@patchew.org; Thu, 17 Oct 2019 08:39:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56330) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL522-00088P-58 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 08:37:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL51z-00070M-OU for qemu-devel@nongnu.org; Thu, 17 Oct 2019 08:37:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17309) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iL51z-0006zo-J1 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 08:37:27 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDABE83F45 for ; Thu, 17 Oct 2019 12:37:25 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id s28so1988811qkm.5 for ; Thu, 17 Oct 2019 05:37:25 -0700 (PDT) Received: from casantos.remote.csb ([177.18.44.193]) by smtp.gmail.com with ESMTPSA id g31sm1242159qte.78.2019.10.17.05.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 05:37:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k4bv22+6vrvmE7LRTGqHXn7bDo6l5gcFE05UN7e9g8Y=; b=cB3GgIsP6UCR3H4bQ0FQmDrv2KYzFNzKSmWtSnRXJ3xRQKTGtk5K3bWr1nYv6Q70OJ 6mKa1kyMx/fCu46ftAELeaOrJ5iAeYIcJ4ZCUzIQRdB/EOJQn7F1H0ghVtUNomlvRNlc pPRko05gbOkJpNCXskMc7kO+SObe4vfkfpG9EwqTVGfI3SwyivV/RT3SscJB4CS0cf3f OWpjLlLcc92aOFIDjnmECQrkShS1ksBxP+7lnMZ/n2mh32dtvrGvrpVHwVSCUaYByM25 7SgTWie1JHg+0+tyukIrot80nXHD20Bmqeb8Iiahodwp1sJpryiV+OLQNybNFCIO/D80 Tiiw== X-Gm-Message-State: APjAAAWIbzBYPA+bgD+4phEAa2a6OLzcCAZmu98vLhcLhbCExwNPhUum 6babNJ5GXE54bY9K6Sf5qgrYlrjUnIRC5bpucQx94IPzaFh7z4fWLOh/H4DINJ6eq/kmxADQC+2 56W54oaUytE1VaFc= X-Received: by 2002:aed:3c67:: with SMTP id u36mr3513798qte.142.1571315844976; Thu, 17 Oct 2019 05:37:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRB4JleuNeb5TiK5uWS7hNhdSBS9cabcD1YUM1fTN1XoCG33nKqOhsnPYti0t2pRJZ75rABw== X-Received: by 2002:aed:3c67:: with SMTP id u36mr3513778qte.142.1571315844725; Thu, 17 Oct 2019 05:37:24 -0700 (PDT) From: casantos@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH] util/cacheinfo: fix crash when compiling with uClibc Date: Thu, 17 Oct 2019 09:37:13 -0300 Message-Id: <20191017123713.30192-1-casantos@redhat.com> X-Mailer: git-send-email 2.18.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlos Santos Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Carlos Santos uClibc defines _SC_LEVEL1_ICACHE_LINESIZE and _SC_LEVEL1_DCACHE_LINESIZE but the corresponding sysconf calls returns -1, which is a valid result, meaning that the limit is indeterminate. Handle this situation using the fallback values instead of crashing due to an assertion failure. Signed-off-by: Carlos Santos --- util/cacheinfo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util/cacheinfo.c b/util/cacheinfo.c index ea6f3e99bf..d94dc6adc8 100644 --- a/util/cacheinfo.c +++ b/util/cacheinfo.c @@ -93,10 +93,16 @@ static void sys_cache_info(int *isize, int *dsize) static void sys_cache_info(int *isize, int *dsize) { # ifdef _SC_LEVEL1_ICACHE_LINESIZE - *isize =3D sysconf(_SC_LEVEL1_ICACHE_LINESIZE); + int tmp_isize =3D (int) sysconf(_SC_LEVEL1_ICACHE_LINESIZE); + if (tmp_isize > 0) { + *isize =3D tmp_isize; + } # endif # ifdef _SC_LEVEL1_DCACHE_LINESIZE - *dsize =3D sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + int tmp_dsize =3D (int) sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + if (tmp_dsize > 0) { + *dsize =3D tmp_dsize; + } # endif } #endif /* sys_cache_info */ --=20 2.18.1