VFS code questions

Kevin M. Kilbride kmk at ssl.org
Fri Feb 25 14:45:29 PST 2005


Joerg Sonnenberger wrote:

Some of this needs to be done to avoid overflows in intermediate results.
 

Perhaps in some instances; however, it cannot be the case that

   return (int64_t) & (int32_t)

will ever overflow. Instead, the int32_t is implicitly promoted to 
int64_t and sign-extended before the bitwise operator is applied. This 
means that, if the smaller mask value can ever be viewed as "negative," 
it will unintentionally leave all high-order bits in the int64_t word 
unmasked. To then rely upon an explicit cast everywhere it is used in 
code to insure that this mangled value never bites anyone seems, to me, 
like playing with fire. If anyone starts extending or changing any of 
these facilities, they must be mindful of the fact that the explicit 
cast is part of the actual masking operation implicit in the macro. If 
they ever forget it, and they attempt to extend to a 64-bit interface 
with code that uses intermediate results, things may fail unexpectedly. 
It doesn't help that these logic relationships are hidden within layers 
of macros.

Don't use __inline__, that's a GNUism. Use __inline, which is a
preprocessor macro defined in sys/cdefs.h and handles unavailability
of inline support correctly.
 

Okay. I'll look over cdefs and see what's available. I wasn't aware that 
there was any interest in providing support for non-system compilers.

That often has historic reasons. I would be *very* careful about
changing it. The best person to consult is Kirk though.
 

Kirk? Kirk who? Are you talking about Kirk McKusick? Does he actually 
hang out around these parts? How would one go about asking him such a 
question?






More information about the Submit mailing list