raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / 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	[thread overview]
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	other threads:[~2013-09-10 19:57 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 [this message]
2013-09-10 20:17       ` Eric Wong
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='CAAB-KcnSoHwcpMPBOdvHascKUsXMngyOhWmeXRJE=ZzP-Xn6-g@mail.gmail.com' \
    --to=375gnu@gmail.com \
    --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).