From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2814074A33; Wed, 2 Jun 2021 16:39:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1E4C9D059; Wed, 2 Jun 2021 16:38:46 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id B5F4FC96F; Wed, 2 Jun 2021 16:38:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8EE40466D8; Wed, 2 Jun 2021 16:38:44 +0200 (CEST) From: Stefan Reiter To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Date: Wed, 2 Jun 2021 16:38:31 +0200 Message-Id: <20210602143833.4423-8-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210602143833.4423-1-s.reiter@proxmox.com> References: <20210602143833.4423-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.224 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_NUMSUBJECT 0.5 Subject ends in numbers excluding current years SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox-backup 7/9] tools/lru_cache: make minimum capacity 1 X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 14:39:16 -0000 Setting this to 0 is not just useless, but breaks the logic horribly enough to cause random segfaults - better forbid this, to avoid someone else having to debug it again ;) Signed-off-by: Stefan Reiter --- src/tools/lru_cache.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/lru_cache.rs b/src/tools/lru_cache.rs index 70289d3f..7c8cf25f 100644 --- a/src/tools/lru_cache.rs +++ b/src/tools/lru_cache.rs @@ -106,6 +106,7 @@ unsafe impl Send for LruCache {} impl LruCache { /// Create LRU cache instance which holds up to `capacity` nodes at once. pub fn new(capacity: usize) -> Self { + let capacity = capacity.min(1); Self { map: HashMap::with_capacity(capacity), list: LinkedList::new(), -- 2.30.2