[RFC]__sock_create() change

pradeep singh 2500.pradeep at gmail.com
Mon May 14 03:12:55 CDT 2007


On 5/14/07, Razvan Deaconescu <razvan at anaconda.cs.pub.ro > wrote:
>
> pradeep singh wrote:
> > Hi All,
> >
> > the __sock_create in net/socket.c has the following code snippet.
> >
> > if (family == PF_INET && type == SOCK_PACKET) {
> >      static int warned;
> >      if (!warned) {
> >           warned = 1;
> >           printk(KERN_INFO "%s uses obsolete (PF_INET,SOCK_PACKET)\n",
> > current->comm);
> >      }
> >      family = PF_PACKET;
> > }
> >
> > this may be in place to emit a harmless warning , but why not change it
> > to -
> > if (family == PF_INET && type == SOCK_PACKET) {
> >
> >      printk(KERN_INFO "%s uses obsolete (PF_INET,SOCK_PACKET)\n",
> > current->comm);
> >
> >      family = PF_PACKET;
> > }
> >
> > Because anyway if(!warning) is going to result in true everytime we
> > enter the function, as static int warning has scope limited to the outer
>
> > if block.
>
> Not quite so. The warning variable may only have scope within its block
> ,but (being static) is stored in a reserved memory area (I think this is
> called linkage ... not sure though). The second time someone would try
> creating a socket using PF_INET and SOCK_PACKET, he/she would not get
> that warning as 'warning' is already set (warning = 1, that is).


You are right indeed, static does have internal linkage.
Messed that up though :-(.

But why would we want
to issues warning only once and not each time the socket is created
for SOCK_PAKCET type?

Thanks for correcting Razvan.

~psr





Razvan
>



-- 
play the game
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/kernel-mentors/attachments/20070514/e3a8cdee/attachment.htm 


More information about the Kernel-mentors mailing list