From: Eric Wong <normalperson@yhbt.net>
To: raindrops@librelist.org
Subject: Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses.
Date: Tue, 10 Sep 2013 20:17:06 +0000 [thread overview]
Message-ID: <20130910201706.GA6250@dcvr.yhbt.net> (raw)
In-Reply-To: CAAB-KcnSoHwcpMPBOdvHascKUsXMngyOhWmeXRJE=ZzP-Xn6-g@mail.gmail.com
Hleb Valoshka <375gnu@gmail.com> wrote:
> On 9/10/13, Eric Wong <normalperson@yhbt.net> wrote:
> >> + newaddr = strdup(addr);
> >> + if (newaddr == NULL)
> >> + perror("strdup");
> >
> > We'll segfault on strchr below if we perrored above. If we continue
> > using strdup, I would just use ruby_strdup() (works on both MRI/rbx).
>
> I haven't use C for a long time, so I thought that strchr checks its args.
>
> > But I'd rather avoid *strdup entirely. This is unlikely to
> > remove, right?
>
> Frankly speaking I dislike functions similar to strdup(), because
> using them you should remember to call free(), sometimes in many
> places (or to use goto). But I'm unfamiliar with internal ruby api, so
> it was the only variant for me.
I try to avoid strdup, too. I can help you with Ruby C API :)
The advantage of creating Ruby strings right away is it maintains
length, so one can use mem* functions instead of str* functions
(always faster and more explicit, often safer, and never less safe).
> BTW, is anything bad with that variant:
> char *newaddr = alloca(...);
> remove_scope_id(oldaddr, newaddr);
Probably OK in this case, but it would need a comment explaining to stack
checkers the size is bounded and won't overflow.
> > Perhaps something like this (totally untested, likely off-by-one errors)
>
> Ok, I'll test your code tomorrow.
Thanks.
next prev parent reply other threads:[~2013-09-10 20:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1378826261-10771-1-git-send-email-375gnu@gmail.com>
[not found] ` <20130910183504.GA502@dcvr.yhbt.net>
2013-09-10 18:36 ` [PATCH] Remove Scope IDs from IPv6 addresses Eric Wong
2013-09-10 19:57 ` Hleb Valoshka
2013-09-10 20:17 ` Eric Wong [this message]
2013-09-11 16:12 ` Hleb Valoshka
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
List information: https://yhbt.net/raindrops/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130910201706.GA6250@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=raindrops@librelist.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.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.git/
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).