[net.unix-wizards] Another pointer size problem

lfm@ukc.UUCP (L.Marshall) (02/22/84)

Another place where pointer sizes can screw you up is in the parameters
to system calls. How many times have you written :

    struct X y;
    read(fd, &y, sizeof(y));

or something similar? This of course *WRONG* and should be :

    read(fd, (char *) &y, sizeof(y));

but how often do you write the coercion? If you had a PERQ (or a PRIME
or a Honeywell...) you would do it all the time (most of the utilities
do it none of the time). So its not just NULL vs 0, at all - let's hear
it for coercions (or do I mean casts?).

  Lindsay F. Marshall
    uucp : ...!(mcvax,vax135)!ukc!lfm
    ARPA : Lindsay_Marshall%NEWCASTLE@MIT-MULTICS
    post : Computing Laboratory, U of Newcastle upon Tyne, U.K.
           +44 - 632 - 329233 xtn 212

guido@mcvax.UUCP (Guido van Rossum) (02/24/84)

Let's stop the whole debate about pointer sizes.
Can't we rely on lint for pointing out nonportable pointer use?
In spite of all the alledged "lint problems" recently found in this group,
it is perfectly capable of doing THAT!

P.S. How ofthen do YOU write

    read(fd, &y, sizeof(y));

in programs that are supposed to be portable?  I for me prefer using
the standard I/O library.

Guido van Rossum, {philabs,decvax}!mcvax!guido
Centre for Mathematics and Computer Science, (CWI, formerly MC), Amsterdam

"Not afraid of writing it twice"

ntt@dciem.UUCP (Mark Brader) (02/27/84)

     How often do YOU write
     
         read(fd, &y, sizeof(y));
     
     in programs that are supposed to be portable?  I for me prefer using
     the standard I/O library.

-------------------------------------------------------
Doesn't the same thing arise with fread?
Don't you need to say:

	fread ((char *)&y, sizeof y, nitems, stream);

...to be sure the compiler will pass the arguments correctly?

Mark Brader
[I haven't used any machines myself where this would matter.]