From: Kamil Rytarowski <n54@gmx.com>
To: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Cc: tom@tromey.com
Subject: Re: [PATCH v4] Implement basic threading support in the NetBSD target
Date: Thu, 2 Apr 2020 21:22:46 +0200 [thread overview]
Message-ID: <4884140c-867a-a0a7-bf03-ff0bc64c8028@gmx.com> (raw)
In-Reply-To: <04ae24e8-3496-a8bb-908d-6f1a2e2f98f5@redhat.com>
On 02.04.2020 21:05, Pedro Alves wrote:
> 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<bool (const struct kinfo_lwp *)>
>> + 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<struct kinfo_lwp> kl
>
> You can use the array variant:
>
> gdb::unique_xmalloc_ptr<struct kinfo_lwp[]>
>
Done.
>> + ((struct kinfo_lwp *) xcalloc (size, 1));
>> + if (kl == NULL)
>> + perror_with_name (("calloc"));
>
> xcalloc doesn't ever return NULL.
>
Done.
>> +
>> + 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];
>
Done.
> Thanks,
> Pedro Alves
>
Please see v5.
next prev parent reply other threads:[~2020-04-02 19:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 2:53 [PATCH] " Kamil Rytarowski
2020-03-26 3:16 ` [PATCH v2] " Kamil Rytarowski
2020-03-30 21:17 ` Kamil Rytarowski
2020-04-01 20:44 ` Tom Tromey
2020-04-01 21:03 ` Kamil Rytarowski
2020-04-01 21:01 ` [PATCH v3] " Kamil Rytarowski
2020-04-01 21:33 ` [PATCH v4] " Kamil Rytarowski
2020-04-02 19:05 ` Pedro Alves
2020-04-02 19:22 ` Kamil Rytarowski [this message]
2020-04-02 19:24 ` [PATCH v5] " Kamil Rytarowski
2020-04-06 7:26 ` Kamil Rytarowski
2020-04-06 20:50 ` Tom Tromey
2020-04-01 20:43 ` [PATCH] " Tom Tromey
2020-04-01 21:39 ` Kamil Rytarowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4884140c-867a-a0a7-bf03-ff0bc64c8028@gmx.com \
--to=n54@gmx.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).