From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 940ED388A02F for ; Thu, 2 Apr 2020 19:05:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 940ED388A02F Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-WKDbjCoiNtOonZzKSZ71tQ-1; Thu, 02 Apr 2020 15:05:51 -0400 X-MC-Unique: WKDbjCoiNtOonZzKSZ71tQ-1 Received: by mail-ed1-f69.google.com with SMTP id cm25so3490899edb.14 for ; Thu, 02 Apr 2020 12:05:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yEQOXvVk+F9hy7pPLC0GaHOO8HsH9CzvtGoTArrybCo=; b=QBn269L2Ob8+zJrKJpBXn4PmljBwV+Opq1v5T7VhS1XqKrcYKnRXU7ZPVHmnYKUfWl I4Kyl1UiFy0ZRNdp5EW3MXwm52AnyVowJqElHHfTc0NLwRLm6ANmmECebCX1GJPsCmz7 GqzPPOdVc1QscUom3eknrFIVoL7lpsuQQnvlZNTeWq00qn11SzyiHFI5CSGm+V9H9Aa2 d8nvV4V4po1lrsJvqVfXEMm7edLEzH9kq5V10p/AoSDCEy2BVoM2MXvPBfCXAy4mXTwp 87N4TmphIoUay336UO7woFRD7xkXCs5JHRNVk2xy2nQAxrtawm5B3y2MTB9WM/4wVQFr l+Qw== X-Gm-Message-State: AGi0PuZ90CdKEBWyRf2/W0gH8omCBTKJNLdR4XyK2TpOqiyEHWCJf9Bd 25ZX54PoHpSoEDk0PPDgx/Z25OSMbg4T7vOfst/PxqG76vaBarTPUeyW54lFlBlm7jfBvrLnidK 16cJDMZzzYPruGOY6c6OZxQ== X-Received: by 2002:a05:6402:44e:: with SMTP id p14mr4513656edw.356.1585854350493; Thu, 02 Apr 2020 12:05:50 -0700 (PDT) X-Google-Smtp-Source: APiQypKTej4UruwhPNUV9WmDcyGyL8MVYrB4/iNzQ+a4FW3HW1jr22FjyTIYAgX4GbGrEuehNi3zJQ== X-Received: by 2002:a05:6402:44e:: with SMTP id p14mr4513645edw.356.1585854350337; Thu, 02 Apr 2020 12:05:50 -0700 (PDT) Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id a24sm1236488ejy.38.2020.04.02.12.05.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Apr 2020 12:05:49 -0700 (PDT) Subject: Re: [PATCH v4] Implement basic threading support in the NetBSD target To: Kamil Rytarowski , gdb-patches@sourceware.org References: <20200401210139.27152-1-n54@gmx.com> <20200401213321.20107-1-n54@gmx.com> Cc: tom@tromey.com From: Pedro Alves Message-ID: <04ae24e8-3496-a8bb-908d-6f1a2e2f98f5@redhat.com> Date: Thu, 2 Apr 2020 20:05:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20200401213321.20107-1-n54@gmx.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 19:05:54 -0000 Hi, I skimmed the patch and noticed a couple nits. On 4/1/20 10:33 PM, Kamil Rytarowski wrote: > +static bool > +nbsd_thread_lister (const pid_t pid, > + gdb::function_view > + callback) > +{ > + int mib[5] = {CTL_KERN, KERN_LWP, pid, sizeof (struct kinfo_lwp), 0}; > + size_t size; > + > + if (sysctl (mib, ARRAY_SIZE (mib), NULL, &size, NULL, 0) == -1 || size == 0) > + perror_with_name (("sysctl")); > + > + mib[4] = size / sizeof (size_t); > + > + gdb::unique_xmalloc_ptr kl You can use the array variant: gdb::unique_xmalloc_ptr > + ((struct kinfo_lwp *) xcalloc (size, 1)); > + if (kl == NULL) > + perror_with_name (("calloc")); xcalloc doesn't ever return NULL. > + > + if (sysctl (mib, ARRAY_SIZE (mib), kl.get (), &size, NULL, 0) == -1 > + || size == 0) > + perror_with_name (("sysctl")); > + > + for (size_t i = 0; i < size / sizeof (struct kinfo_lwp); i++) > + { > + struct kinfo_lwp *l = &kl.get ()[i]; If you use the array variant, then here you don't need the .get(), like: struct kinfo_lwp *l = &kl[i]; Thanks, Pedro Alves