Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: srt@zaphod.csci.unt.edu (Steve Tate)
Subject: Re: Strange error in STREAMS code
Date: 13 Nov 1994 23:24:53 GMT	[thread overview]
Message-ID: <3a6785$agm@hermes.unt.edu> (raw)
In-Reply-To: 3a5nmv$4n4@hermes.unt.edu

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                 |


  reply	other threads:[~1994-11-13 23:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-13 18:59 Strange error in STREAMS code Steve Tate
1994-11-13 23:24 ` Steve Tate [this message]
1994-11-13 23:48   ` John Hascall
1994-11-14 16:34     ` Steve Tate
1994-11-14 19:13       ` John Hascall
1994-11-14 22:32       ` Charles M Richmond
1994-11-15  4:00         ` John Hascall
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox