[openbeosnetteam] Re: CVS: net_kit/source/driver net_stack_driver.c,1.4,1.5

> Modified Files:
>       net_stack_driver.c 
> Log Message:
> Fix some style lines...
> 
> connect should return -1 in a failure case with the exact error being 
> available via errno, which is what this change does. I'm guessing the 
same 
> is true for a number of other functions, and ISTR that it used to be 
like this,
> so why did we change it?

In the net_stack_control() hook, the function eturn values are B_OK or 
B_ERROR because 
it's the way the ioctl() syscall expect them (and interpret them).
These return values says: this ioctl(opcode) WAS or WAS NOT handled.
And don't forget a ioctl(fd, opcode) could fail too, for many 
reasons (bad fd, closed fd, internal vfs problem, internal devfs 
failure, 
you name it...)

It's why we need all these 'rv' in the *_args structs we use between 
libnet.so and 
net_stack_driver.c, and why in libnet.so we both check the ioctl() call 
result and, 
if the opcode was really handled (ioctl returns B_OK), then use the 
corresponding *_args struct return value, stored in the 'rv' field:

  args.rv = B_ERROR;
  rv = ioctl(sock, NET_STACK_CONNECT, &args, sizeof(args));
  return (rv < 0) ? rv : args.rv;

On this same topic, I'm not sure that from kernelland the errno is 
thread-safe. Need to 
be checked...

-Philippe.




--
Fortune Cookie Says:

Although the moon is smaller than the earth, it is farther away.


Other related posts: