casting args to functions...

Brandon Allbery brandon at tdi2.UUCP
Tue Nov 11 08:59:33 AEST 1986


Expires:


Quoted from <5068 at ukme.ukma.uky.csnet> ["Re: Microport Unix -- Large Model Problems"], by david at ukma.uky.csnet (David Herron, NPR Lover)...
+---------------
| In article <840 at ur-valhalla.UUCP> dave at valhalla.UUCP (Dave Carlson) writes:
| >A potential problem I smacked into yesterday when porting BSD to SV/AT
| >is ioctl(2) expects as the third argument:
| >union   { int iarg;
| >        char *cparg;}
| >Problem is that the union will pull 4 bytes off the stack (in large model)
| >but the program calling with an integer will only push 2 bytes.  Oh S*$&!
| >I cast my integer args long and everything seems ok but what a pain...
| 
| Argh!  And you're doing a port of an operating system???
| 
| UNIONS are the SAME size regardless of WHICH part of them you use!
| 
| A user which passes an int to a routine expecting a union is ASKING
| for trouble!
+---------------

The problem is not this:  it is that ioctl() is documented as taking a pointer
in some places and as taking an int in others.  Please note that it is not
documented as taking a union, or is the "int" changed to a "long" on machines
with 2-byte integers and 4-byte pointers.  Berkeley int==long-ism strikes
again!

++Brandon
-- 
 /-----------//***/  Brandon S. Allbery		cbosgd!cwruecmp!ncoast!allbery
/---   -----//***/   Tridelta Industries, Inc.  ihnp4!tft2!tdi2!brandon
  /  //---, /---/    7350 Corporate Blvd.      		       !ncoast!allbery
 /  //   / /   /     Mentor, OH 44060
/--//---' /---/      +1 216 255 1080		HOME: +1 216 974 9210



More information about the Comp.unix.wizards mailing list