From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 244C03858D1E for ; Mon, 9 Oct 2023 14:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 244C03858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696860097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O1jCp7Ah5QZ31V21uvhvWw/1Kz2NopDS1nYlh0Ddn74=; b=XQ3Ov/l2rgeKovN4bRKxCSBhTLHy+1lto3GAtVK4KkqmueT3Uc/qPKh4vh6ZI7auTIqNW5 EffGTgWawcot55R0sriT25AypdKB2YO3/BpjrQsAUn8f24K0f8ykWU6+yui9FY4zPBvp+4 efIpdezwA2To50gaEH1NpjFgpL0/EdA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-yHJOE_KWPSS7a1rPht4GsQ-1; Mon, 09 Oct 2023 10:01:36 -0400 X-MC-Unique: yHJOE_KWPSS7a1rPht4GsQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7742eeceeacso607822085a.3 for ; Mon, 09 Oct 2023 07:01:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696860096; x=1697464896; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O1jCp7Ah5QZ31V21uvhvWw/1Kz2NopDS1nYlh0Ddn74=; b=MPjoXc4IjLqpgsS+KvQqA3gVbBN4p3sivG5I6i+LC2RL+5lXRuzgzN706dZR2Ds7WC Wsi0A/rSqtaKMmuWNm79qp8u5XvZC1yWCbOx6KVb/4H4WkLBdsVvFRzZzHbCot23X5Np +n4t8GLcUlFKMy6cGyCTLAICLCTCbeEDhuHPUMBX80Vt7k05N5jORETHoha5p0JCYGzc 9ZqzZXzqxtCqVaAWO4wUdR8Nv4LPZ++IiWn2mYIcL9fLR1zsNTnV2ob86BSMt6kSf8HJ 4K/SQ37YgOslT4gM8VdQoVCK8L72WXC9rKOK13Iz0RTowiKdh0hSLm35v1sGJGt1rgFC PheQ== X-Gm-Message-State: AOJu0YxCcQ/IpRWTm4VCoMi9iBRqS/zKw+Pp3KHh6eqPrwVZu7L7QuEd FGIVCAeUO40W76bjs/T7udgBwpCMgwMSnKspeGH1QFNDAKNWjEc9ntmZd/f0g8Bgg2WSo5bRYJB 6T21ZtoFaWpWryEdL6w== X-Received: by 2002:a05:620a:1990:b0:775:72b7:9300 with SMTP id bm16-20020a05620a199000b0077572b79300mr19912898qkb.20.1696860095741; Mon, 09 Oct 2023 07:01:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKH/1M1AfuS9ut2mHke0eafwkyfoPiaijGreoQcZXwfoFh0+u3/4MjI+F57jw4scpfObpTuw== X-Received: by 2002:a05:620a:1990:b0:775:72b7:9300 with SMTP id bm16-20020a05620a199000b0077572b79300mr19912875qkb.20.1696860095438; Mon, 09 Oct 2023 07:01:35 -0700 (PDT) Received: from [192.168.1.11] ([80.168.197.243]) by smtp.gmail.com with ESMTPSA id c28-20020a05620a135c00b0076f21383b6csm3541218qkl.112.2023.10.09.07.01.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Oct 2023 07:01:34 -0700 (PDT) Message-ID: <6bd18d16-728f-88c8-c31d-83a9f594a752@redhat.com> Date: Mon, 9 Oct 2023 15:01:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: Andrew Burgess , binutils@sourceware.org References: From: Nick Clifton Subject: Re: [PATCH] bfd: add new bfd_cache_size() function In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Andrew, > And so, to support this, I would like to add a new bfd_cache_size > function. This function returns an integer, which is the number of > open files in the cache. I can then start adding: > > gdb_assert (bfd_cache_size() == 0); > > to GDB in some strategic spots, and start fixing all of the missing > bfd_cache_close_all calls that crop up as a result. Patch approved - please apply. If you are feeling motivated then there is an associated change that it would be nice to see made: > +/* > +FUNCTION > + bfd_cache_size > + > +SYNOPSIS > + int bfd_cache_size (void); > + > +DESCRIPTION > + Return the number of open files in the cache. > +*/ It does not make sense for this function to return a negative value. (Or maybe it does - a negative value would indicate that the cache does not exist, whereas 0 would indicate that it does exist, but it is empty ?). So if bfd_cache_size() returns an unsigned int then bfd_cache_max_open() should as well, and the files_open and max_files_open variables should be changed as well. Of course in practice we should never see negative values or large values for any of these variables/function-results, so using an "int" should be just fine. But it bugs me that functions and variables which should never have negative values are being typed as if they could have them. Cheers Nick