ws2_32: Add support for FROM_PROTOCOL_INFO to WSASocket()

Kai Blin kai.blin at gmail.com
Sun May 25 13:00:34 CDT 2008


On Sunday 25 May 2008 16:19:24 Dmitry Timoshkov wrote:

> > @@ -314,6 +316,7 @@ static const int ws_proto_map[][2] =
> >      MAP_OPTION( IPPROTO_ICMP ),
> >      MAP_OPTION( IPPROTO_IGMP ),
> >      MAP_OPTION( IPPROTO_RAW ),
> > +    {FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO},
> >  };
>
> Although it was the case before, it's a mistake to have a comma after
> the last struct member initializer.

It is?  K&R seems to use both, so I preferred to keep it similar to all the 
other struct member initializers.

> > +    if (lpProtocolInfo) {
> > +      if (af == FROM_PROTOCOL_INFO)
> > +          af = lpProtocolInfo->iAddressFamily;
> > +      if (type == FROM_PROTOCOL_INFO)
> > +          type = lpProtocolInfo->iSocketType;
> > +      if (protocol == FROM_PROTOCOL_INFO)
> > +          protocol = lpProtocolInfo->iProtocol;
>
> Please keep opening brace style/indentation consistent with code you have
> removed.

The function is a mess with brace style and indentation. I've used the same 
indentaion as the if right above this one. The function wildly mixes 
two-space, three-space and four-space indents. In this case, I used two-space 
indents for the outer if and four-space indents for the inner ifs for better 
readability.

> > --- a/include/winsock.h
> > +++ b/include/winsock.h
> > @@ -146,6 +146,7 @@ extern "C" {
> >  /* proper 4-byte packing */
> >  #include <pshpack4.h>
> >
> > +#define FROM_PROTOCOL_INFO (-1)
>
> PSDK has it in winsock2.h

PSDK has the AF_*, PF_*, SOCK_* and IPPROTO_* defines in winsock2.h as well, 
Wine hasn't. I preferred to keep them together.

I don't fully understand why people suddenly start getting picky about stuff 
like this when noone previously gave a damn. As it's not acceptable to just 
go over this mess with indent, I don't see how conforming to one sort of 
messy indentation is preferrable to another sort of messy indentation.

Seriously, this patch fixes a bug, take it or leave it and fix it yourself.
Kai

-- 
Kai Blin
WorldForge developer  http://www.worldforge.org/
Wine developer        http://wiki.winehq.org/KaiBlin
Samba team member     http://www.samba.org/samba/team/
--
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20080525/fdf54b03/attachment.pgp 


More information about the wine-devel mailing list