ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: d. caratti <davide.caratti@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 1/2] avoid using inet_ntoa()
Date: Mon, 07 Jun 2021 19:00:52 +0200	[thread overview]
Message-ID: <CAJ6EMK04dtBF3JmHNmmBgin1cjLZXSGQc71M3sBLSyLS03ib+w@mail.gmail.com> (raw)
In-Reply-To: <2582f783-6333-86a5-32e3-fe6c0deb4e37@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

hello Denis, thanks for reviewing!

Il giorno ven 4 giu 2021 alle ore 18:01 Denis Kenzior <denkenz@gmail.com>
ha scritto:

> Hi Davide,
>

[...]


> Strictly speaking the examples/ change should be in its own patch.  See
> HACKING.
>

I should have read it, as well as the coding style rules, before submitting
_ sorry for not doing that.
I will address coding style and remove SOB line in the v2.

[...]

> @@ -911,9 +923,10 @@ static void dhcp_client_rx_message(const void *data,
> size_t len, void *userdata)
> >               ia.s_addr = client->lease->address;
> >
> >               /* For unit testing we don't want this to be a fatal error
> */
> > -             if (!l_acd_start(client->acd, inet_ntoa(ia))) {
> > +             if (!inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN) ||
> > +                 !l_acd_start(client->acd, buf)) {
> >                       CLIENT_DEBUG("Failed to start ACD on %s,
> continuing",
> > -                                             inet_ntoa(ia));
> > +                                  IP_STR(ia.s_addr));
>
> Not sure introducing IP_STR macro just for this is worth it, but ok...
>

that might be useful for other future CLIENT_DEBUG() users.

[...]


> Looks like indentation problem here too.  Maybe you want to put the
> inet_ntop
> business outside of l_strdup_printf call to make things more readable?
>

yes, it seems to look better - I will also fix this.
By the way, looking at the inet_ntop() documentation [1], I think that I
can also avoid things like

   inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN) ? : "(inv)";

because the first argument is hardcoded to AF_INET and also we are sure
that 'buf' is INET_ADDRSTRLEN long.
Under these conditions, the return value of inet_ntop() should always be
'buf'. Correct?

--
davide

[1] https://man7.org/linux/man-pages/man3/inet_ntop.3.html
RispondiInoltra

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 6281 bytes --]

  reply	other threads:[~2021-06-07 17:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:50 [PATCH 0/2] avoid using inet_ntoa() and inet_aton() Davide Caratti
2021-06-03  9:50 ` [PATCH 1/2] avoid using inet_ntoa() Davide Caratti
2021-06-04 16:01   ` Denis Kenzior
2021-06-07 17:00     ` d. caratti [this message]
2021-06-07 18:41       ` Denis Kenzior
2021-06-08 12:46         ` d. caratti
2021-06-08 16:22           ` Denis Kenzior
2021-06-09 10:18             ` d. caratti
2021-06-10 22:12               ` Denis Kenzior
2021-06-03  9:50 ` [PATCH 2/2] avoid using inet_aton() Davide Caratti
2021-06-04 15:41   ` Denis Kenzior

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=CAJ6EMK04dtBF3JmHNmmBgin1cjLZXSGQc71M3sBLSyLS03ib+w@mail.gmail.com \
    --to=davide.caratti@gmail.com \
    --cc=ell@lists.01.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;
as well as URLs for NNTP newsgroup(s).