From: john@iastate.edu (John Hascall)
Subject: Re: Strange error in STREAMS code
Date: 13 Nov 1994 23:48:52 GMT [thread overview]
Message-ID: <3a68l4$nf0@news.iastate.edu> (raw)
In-Reply-To: 3a6785$agm@hermes.unt.edu
Steve Tate <srt@zaphod.csci.unt.edu> wrote:
}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.
From "man ioctl":
#include <sys/ioctl.h>
ioctl(
int d,
unsigned long request, <--- looks like it is intentional
char *argp ); that they are 64 bits.
I guess you should declare i->ioc_cmd as "unsigned long" too.
John
--
John Hascall ``An ill-chosen word is the fool's messenger.''
Systems Software Engineer, ISU Comp Center + Ames, IA 50011 + 515/294-9551
& Hascall Systems - Unix/C/Internet Consulting, Training, Custom Programming
next prev parent reply other threads:[~1994-11-13 23:48 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
1994-11-13 23:48 ` John Hascall [this message]
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