From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,47c3c23c50f4dcda X-Google-Attributes: gidfee84,public X-Google-Thread: 1164f8,47c3c23c50f4dcda X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-11-16 04:58:21 PST Path: nntp.gmd.de!xlink.net!news.acotec.de!cs.tu-berlin.de!zrz.TU-Berlin.DE!netmbx.de!Germany.EU.net!news.dfn.de!swiss.ans.net!howland.reston.ans.net!cs.utexas.edu!news.unt.edu!zaphod!srt From: srt@zaphod.csci.unt.edu (Steve Tate) Newsgroups: comp.sys.dec,comp.unix.osf.osf1 Subject: Re: Strange error in STREAMS code Followup-To: comp.sys.dec,comp.unix.osf.osf1 Date: 13 Nov 1994 23:24:53 GMT Organization: University of North Texas Distribution: world Message-ID: <3a6785$agm@hermes.unt.edu> References: <3a5nmv$4n4@hermes.unt.edu> NNTP-Posting-Host: zaphod.csci.unt.edu X-Newsreader: TIN [version 1.2 PL2] Xref: nntp.gmd.de comp.sys.dec:19718 comp.unix.osf.osf1:6500 I'm following up on my own posting, because now I know WHAT is going on, and it seems to me like the problem lies in the way things are defined in the standard include files. Here's the poop: The variable i->ioc_cmd is of type int, so gets loaded into a 64-bit register with sign extension. The highest bit is set in my example, so the high longword gets filled with ones. All of the ioctl codes defined with _IOW(..) are of the form (0x80000000 | .. | sizeof(.)), and the sizeof() operator makes this whole constant expression actually to be of type long (maybe unsigned long, I'm not sure.... but it is an 8 byte data type). Thus when this value is used in a 64-bit register, it is NOT sign extended, and the high longword is zero. Thus the equality test will always be false. Now ALL "write ioctl's" have the high bit set, and the ioctl codes are defined through _IOW(..). Since this is the case, it doesn't seem like an equality test will EVER succeed between an ioc_cmd and an ioctl code (constant). Isn't this a fairly severe error in the include file definitions? Shouldn't, for example, _IOW(..) (or _IOC(..)) include a cast to type int? I am fixing my code by casting ever single ioctl constant code to an int, but that shouldn't really be unnecessary.... -- Steve Tate --- srt@cs.unt.edu | Conservatives: People who think that Dept. of Computer Sciences | nothing should be done for the first University of North Texas | time. Denton, TX 76201 |