> Ok, I can't resist.  Please keep in mind I don't know anything about 
> the coding conventions for this project.  But wouldn't it be better 
> to adopt a convention that uses something like WORD16 and WORD32 for 
> dealing with memory, since int, long, and short can all be compiler 
> dependent?

As long as these are kept to the lowest level possible (only accessing
physical device structures), it's not a problem.

Typedefs like this often cause more problems than they solve, because
eventually someone is going to try to write to an "int" sized memory
location using a "WORD32*" or to a "WORD16" sized memory location using
and "int*".



> 
> e.g.:
> 
> -----<in the appropriate header:>-----
> 
> typedef unsigned long WORD32;
> typedef unsigned int WORD16;
                   ^^^
                   short is better.

> typedef unsigned short BYTE; /* isn't (unsigned char) safer? */
                   ^^^^^
                   short is wrong, char is correct.

> -----<in fs/select.c:>-----
> 
> WORD16 peekw( BYTE *x );
> 
> WORD32 peekd( BYTE *x )
> {
>     return peekw( x ) | ( peekw( x + 2 ) << 16 );
>     /* or return peekw( &x[0] ) | ( peekw( &x[2] ) << 16 ); */
> }

This would not work as BYTE is defined above.
> 
> 
> I'm not sure whether typedefs or #defines would be better.

typedefs are definitely better than defines.

Eric

Reply via email to