raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
From: Hleb Valoshka <375gnu@gmail.com>
To: raindrops@librelist.org
Subject: Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses.
Date: Tue, 10 Sep 2013 22:57:33 +0300
Message-ID: <CAAB-KcnSoHwcpMPBOdvHascKUsXMngyOhWmeXRJE=ZzP-Xn6-g@mail.gmail.com> (raw)
In-Reply-To: <20130910183630.GB502@dcvr.yhbt.net>

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.

BTW, is anything bad with that variant:
char *newaddr = alloca(...);
remove_scope_id(oldaddr, newaddr);

> Perhaps something like this (totally untested, likely off-by-one errors)

Ok, I'll test your code tomorrow.

  reply index

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   ` Eric Wong
2013-09-10 19:57     ` Hleb Valoshka [this message]
2013-09-10 20:17       ` Eric Wong
2013-09-11 16:12         ` Hleb Valoshka

Reply instructions:

You may reply publically 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:

  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='CAAB-KcnSoHwcpMPBOdvHascKUsXMngyOhWmeXRJE=ZzP-Xn6-g@mail.gmail.com' \
    --to=375gnu@gmail.com \
    --cc=raindrops@librelist.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

raindrops RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://yhbt.net/raindrops-public
	git clone --mirror http://ou63pmih66umazou.onion/raindrops-public

Example config snippet for mirrors

Newsgroups are available over NNTP:

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git