Constant and NonConstant Parameter Annotations
For functions that either require or prohibit the use of literal constants as parameters, use the following annotations.
__drv_constant
__drv_nonConstant
Examples
A device driver should not assume that any port address is a constant. Therefore, the various READ_PORT_* functions are all annotated with __drv_nonConstant for the address of the port being read. (The occasional exception to this is best handled by either ignoring or suppressing the PFD warning.)
Another example is the Wait parameter to KeSetEvent. Although in theory that parameter might be a variable, the requirements for what must be done before and after the call make it difficult and possibly confusing to call it with a variable. Therefore, Wait is annotated with __drv_constant. (Again, the occasional exception can be handled by ignoring or suppressing the PFD warning.)
LONG
KeSetEvent(
__in PRKEVENT Event
__in KPRIORITY Increment
__in __drv_constant BOOLEAN Wait
);
Send comments about this topic to Microsoft
Build date: 5/3/2011