Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(302)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 4129042: code review 4129042: net: There's no need for prefixBefore() function.

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 11 months ago by ola
Modified:
2 years, 2 months ago
Reviewers:
rsc
CC:
rsc, golang-dev
Visibility:
Public.
net: There's no need for prefixBefore() function. net or netProto argument are a choice of constants strings. It's not necessary to search a prefix in it. Actual code permit to write 'Dial("tcp:foobarbazquux", "", host) which may lead to confusion. ListenPacket() is modified to permit a net:proto string

Patch Set 1 : code review 4129042: net: There's no need for prefixBefore() function. #

Patch Set 2 : diff -r 3972eb64f7cd https://go.googlecode.com/hg/ #

Created: 14 years, 11 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+19 lines, -23 lines) Patch
M src/pkg/net/dial.go View 1 3 chunks +17 lines, -11 lines 0 comments Download
M src/pkg/net/iprawsock.go View 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/net/parse.go View 1 chunk +0 lines, -10 lines 0 comments Download
Total messages: 12
|
ola
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change.
14 years, 11 months ago (2011年02月01日 16:09:16 UTC) #1
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),
I'd like you to review this change.
Sign in to reply to this message.
rsc
It's not true that prefixBefore is unused. Look at ipraw_test.go, which calls ListenIP on "ip4:icmp". ...
14 years, 11 months ago (2011年02月01日 19:16:52 UTC) #2
It's not true that prefixBefore is unused.
Look at ipraw_test.go, which calls ListenIP on "ip4:icmp".
Russ
Sign in to reply to this message.
ola
On Tue, Feb 1, 2011 at 8:16 PM, Russ Cox <rsc@golang.org> wrote: > It's not ...
14 years, 11 months ago (2011年02月01日 21:36:53 UTC) #3
On Tue, Feb 1, 2011 at 8:16 PM, Russ Cox <rsc@golang.org> wrote:
> It's not true that prefixBefore is unused.
> Look at ipraw_test.go, which calls ListenIP on "ip4:icmp".
>
Argument netProto is processed by netProtoSplit() on ListenIP() which behave
the same as prefixBefore() if there is only one ':'
-- 
Olivier Antoine
Sign in to reply to this message.
rsc
On Tue, Feb 1, 2011 at 16:36, Olivier ANTOINE <olivier.antoine@gmail.com> wrote: > On Tue, Feb ...
14 years, 11 months ago (2011年02月01日 21:44:24 UTC) #4
On Tue, Feb 1, 2011 at 16:36, Olivier ANTOINE <olivier.antoine@gmail.com> wrote:
> On Tue, Feb 1, 2011 at 8:16 PM, Russ Cox <rsc@golang.org> wrote:
>>
>> It's not true that prefixBefore is unused.
>> Look at ipraw_test.go, which calls ListenIP on "ip4:icmp".
>
> Argument netProto is processed by netProtoSplit() on ListenIP() which behave
> the same as prefixBefore() if there is only one ':'
Okay, but what about ListenPacket("ip4:icmp", laddr)?
I agree that it could possibly go in Dial, but maybe there
should be a stricter check?
Russ
Sign in to reply to this message.
ola
On Tue, Feb 1, 2011 at 10:44 PM, Russ Cox <rsc@golang.org> wrote: > On Tue, ...
14 years, 11 months ago (2011年02月02日 09:58:29 UTC) #5
On Tue, Feb 1, 2011 at 10:44 PM, Russ Cox <rsc@golang.org> wrote:
> On Tue, Feb 1, 2011 at 16:36, Olivier ANTOINE <olivier.antoine@gmail.com>
> wrote:
> > On Tue, Feb 1, 2011 at 8:16 PM, Russ Cox <rsc@golang.org> wrote:
> >>
> >> It's not true that prefixBefore is unused.
> >> Look at ipraw_test.go, which calls ListenIP on "ip4:icmp".
> >
> > Argument netProto is processed by netProtoSplit() on ListenIP() which
> behave
> > the same as prefixBefore() if there is only one ':'
>
> Okay, but what about ListenPacket("ip4:icmp", laddr)?
>
Is it allowed ? The documentation for this function states that the "network
string net must be a packet-oriented network: "udp", "udp4", "udp6", or
"unixgram". :)
prefixBefore() just discard the proto part (":icmp" in your example). So
ListenPacket("ip4:icmp", laddr) is strictly equivalent to
ListenPacket("ip4", laddr) which is strictly equivalent to
ListenPacket("ip4:foo", laddr) according to the code. If we care about that
proto part, we should probably use netProtoSplit() on top of ListenPacket()
and rename the 'net' argument to 'netProto' to be consistent, just like in
ListenIP() and DialIP does. But is it usefull ?
I agree that it could possibly go in Dial, but maybe there
> should be a stricter check?
netProtoSplit() do an internal check in order to see if the proto part of
the netProto argument is valid. We can use it everywhere it's needed.
-- 
Olivier Antoine
Sign in to reply to this message.
rsc
> Is it allowed ? The documentation for this function states that the "network > ...
14 years, 11 months ago (2011年02月09日 05:29:10 UTC) #6
> Is it allowed ? The documentation for this function states that the "network
> string net must be a packet-oriented network: "udp", "udp4", "udp6", or
> "unixgram". :)
> prefixBefore() just discard the proto part (":icmp" in your example). So
> ListenPacket("ip4:icmp", laddr) is strictly equivalent to
> ListenPacket("ip4", laddr) which is strictly equivalent to
> ListenPacket("ip4:foo", laddr) according to the code. If we care about that
> proto part, we should probably use netProtoSplit() on top of ListenPacket()
> and rename the 'net' argument to 'netProto' to be consistent, just like in
> ListenIP() and DialIP does. But is it usefull ?
I would like ListenPacket("ip4:anything", laddr) to be
equivalent to ListenIP("ip4:anything", packet).
I don't think the parameter name needs to change.
I would be happy, though, to see the : trigger
unknown network names for all the other networks.
Russ
Sign in to reply to this message.
ola
*** Abandoned ***
14 years, 11 months ago (2011年02月10日 16:46:57 UTC) #7
*** Abandoned ***
Sign in to reply to this message.
ola
On 2011年02月09日 05:29:10, rsc wrote: > > Is it allowed ? The documentation for this ...
14 years, 11 months ago (2011年02月10日 16:51:55 UTC) #8
On 2011年02月09日 05:29:10, rsc wrote:
> > Is it allowed ? The documentation for this function states that the "network
> > string net must be a packet-oriented network: "udp", "udp4", "udp6", or
> > "unixgram". :)
> > prefixBefore() just discard the proto part&nbsp;(":icmp" in your example).
So
> > ListenPacket("ip4:icmp", laddr) is strictly equivalent to
> > ListenPacket("ip4", laddr) which is strictly equivalent to
> > ListenPacket("ip4:foo", laddr) according to the code. If we care about that
> > proto part, we should probably use netProtoSplit() on top
of&nbsp;ListenPacket()
> > and rename the 'net' argument to 'netProto' to be consistent, just like in
> > ListenIP() and DialIP does. But is it usefull ?
> 
> I would like ListenPacket("ip4:anything", laddr) to be
> equivalent to ListenIP("ip4:anything", packet).
> I don't think the parameter name needs to change.
> I would be happy, though, to see the : trigger
> unknown network names for all the other networks.
> 
> Russ
Argh ! I can't upload a new patchset !
'hg mail 4129042' sends some weirds things to codereview and I don't know how to
fix...
Do I need to make a new codereview ?
Sign in to reply to this message.
ola
Hello golang-dev@googlegroups.com, rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
14 years, 11 months ago (2011年02月10日 18:43:21 UTC) #9
Hello golang-dev@googlegroups.com, rsc (cc: golang-dev@googlegroups.com),
I'd like you to review this change to
https://go.googlecode.com/hg/ 
Sign in to reply to this message.
rsc
LGTM
14 years, 11 months ago (2011年02月11日 19:58:52 UTC) #10
LGTM
Sign in to reply to this message.
rsc
LGTM But please complete a CLA as described at http://golang.org/doc/contribute.html#copyright Thanks.
14 years, 11 months ago (2011年02月11日 20:00:03 UTC) #11
LGTM
But please complete a CLA as described at
http://golang.org/doc/contribute.html#copyright
Thanks.
Sign in to reply to this message.
rsc
*** Submitted as 24f5f929d319 *** net: reject invalid net:proto network names R=rsc CC=golang-dev http://codereview.appspot.com/4129042 Committer: ...
14 years, 11 months ago (2011年02月16日 20:03:51 UTC) #12
*** Submitted as 24f5f929d319 ***
net: reject invalid net:proto network names
R=rsc
CC=golang-dev
http://codereview.appspot.com/4129042
Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.
|
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /