Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Kamil Rytarowski <n54@gmx.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 20:05:48 +0100	[thread overview]
Message-ID: <04ae24e8-3496-a8bb-908d-6f1a2e2f98f5@redhat.com> (raw)
In-Reply-To: <20200401213321.20107-1-n54@gmx.com>

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[]>

> +    ((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



  reply	other threads:[~2020-04-02 19:05 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 [this message]
2020-04-02 19:22         ` Kamil Rytarowski
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=04ae24e8-3496-a8bb-908d-6f1a2e2f98f5@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=n54@gmx.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