From: Ahmad Gani <reyuki@gnuweeb.org>
To: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
"GNU/Weeb Mailing List" <gwml@vger.gnuweeb.org>
Subject: Re: [PATCH gwproxy v4 4/6] dnslookup: Initial work for implementation of C-ares-like getaddrinfo function
Date: Wed, 6 Aug 2025 15:40:39 +0700 [thread overview]
Message-ID: <CAADvAgp5+jPbpjhnMrDnrhKVqnBAu+o4X8J9GemunBuLK_P=jA@mail.gmail.com> (raw)
In-Reply-To: <CAOG64qNEemL4pJoNyHodv2-QtKbTKr=tmFwvSqWbJq=YGQi=CA@mail.gmail.com>
On Wed, Aug 6, 2025 at 1:41 PM Alviro Iskandar Setiawan wrote:
> On Wed, Aug 6, 2025 at 10:57 AM Ahmad Gani wrote:
> > +int gw_ares_init(gw_ares_channel_t **channel, struct gw_ares_options *opts)
> > +{
> > + gw_ares_channel_t *c;
> > + int ret;
> > +
> > + if (!opts->nr_server)
> > + return -EINVAL;
> > +
> > + c = malloc(sizeof(*c));
> > + if (!c)
> > + return -ENOMEM;
> > +
> > + *channel = c;
> > + c->nr_server = opts->nr_server;
> > + c->servers = malloc(c->nr_server * sizeof(*c->servers));
> > + if (!c->servers) {
> > + free(c);
> > + return -ENOMEM;
> > + }
> > + /*
> > + * TODO(reyuki): validate flags and
> > + * for now use it to control recursion desired (RD) bit?
> > + */
> > + c->flags = opts->flags;
> > + for (int i = 0; i < c->nr_server; i++) {
> > + ret = convert_str_to_ssaddr(opts->servers[i], &c->servers[i], DEFAULT_DOMAIN_PORT);
> > + if (ret) {
> > + free(c->servers);
> > + free(c);
> > + return ret;
> > + }
> > + }
> > +
> > + return 0;
> > +}
>
> Again, I don't see any point in filling `*channel` with a dangling
> pointer on error.
>
> This part "*channel = c", can't you do that only when successful?
>
> Please address the previous review properly. Don't ignore comments.
Eh, sorry—I overlooked that. I didn't recheck it because I assumed it was
acceptable, since there were no comments on patchset v2 where the change
was first made. By "avoiding a dangling pointer", I thought the request
meant not to assign to the channel if memory allocation for c failed.
Anyway, don't worry, I will update it in the next patchset.
--
Ahmad Gani
next prev parent reply other threads:[~2025-08-06 8:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 3:57 [PATCH gwproxy v4 0/6] Initial work for DNS lookup implementation Ahmad Gani
2025-08-06 3:57 ` [PATCH gwproxy v4 1/6] dnslookup: Split common functionality and struct into net.h and net.c Ahmad Gani
2025-08-06 6:18 ` Alviro Iskandar Setiawan
2025-08-06 3:57 ` [PATCH gwproxy v4 2/6] dnslookup: Add a new parameter default_port Ahmad Gani
2025-08-06 6:20 ` Alviro Iskandar Setiawan
2025-08-06 3:57 ` [PATCH gwproxy v4 3/6] dnslookup: Allow only port string number Ahmad Gani
2025-08-06 3:57 ` [PATCH gwproxy v4 4/6] dnslookup: Initial work for implementation of C-ares-like getaddrinfo function Ahmad Gani
2025-08-06 6:40 ` Alviro Iskandar Setiawan
2025-08-06 6:51 ` Alviro Iskandar Setiawan
2025-08-06 8:43 ` Ahmad Gani
2025-08-06 8:40 ` Ahmad Gani [this message]
2025-08-06 11:09 ` Alviro Iskandar Setiawan
2025-08-06 11:20 ` Alviro Iskandar Setiawan
2025-08-06 11:39 ` Ammar Faizi
2025-08-06 12:30 ` Ahmad Gani
2025-08-06 20:54 ` Ammar Faizi
2025-08-06 12:30 ` Ahmad Gani
2025-08-06 21:33 ` Ammar Faizi
2025-08-14 4:54 ` Ahmad Gani
2025-08-06 3:57 ` [PATCH gwproxy v4 5/6] dnsparser: Transaction id creation is delegated to caller Ahmad Gani
2025-08-06 6:28 ` Alviro Iskandar Setiawan
2025-08-06 10:20 ` Ahmad Gani
2025-08-06 10:51 ` Alviro Iskandar Setiawan
2025-08-06 12:29 ` Ahmad Gani
2025-08-06 3:57 ` [PATCH gwproxy v4 6/6] dnslookup: Make gw_ares_getaddrinfo asynchronous Ahmad Gani
2025-08-06 6:22 ` Alviro Iskandar Setiawan
2025-08-06 8:42 ` Ahmad Gani
2025-08-06 7:03 ` [PATCH gwproxy v4 0/6] Initial work for DNS lookup implementation Ammar Faizi
2025-08-06 7:08 ` Ammar Faizi
2025-08-06 8:37 ` Ahmad Gani
2025-08-06 8:58 ` Ammar Faizi
2025-08-06 9:47 ` Ammar Faizi
2025-08-06 20:50 ` Ammar Faizi
2025-08-06 22:14 ` Ammar Faizi
2025-08-06 7:08 ` (subset) " Ammar Faizi
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='CAADvAgp5+jPbpjhnMrDnrhKVqnBAu+o4X8J9GemunBuLK_P=jA@mail.gmail.com' \
--to=reyuki@gnuweeb.org \
--cc=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gnuweeb.org \
--cc=gwml@vger.gnuweeb.org \
/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