Tdibuildsend macro

TdiBuildSend (
	Irp,
	DeviceObject,
	WorkThreadCtx->fileobject,
	NULL,							// Completion routine
	NULL,							// Completion context
	Mdl,							// Data
	0,								// Flags
	nMsgLen						// Send Length
	) ;

This is a windows macro used in my driver, On compiling in vs2019, this is giving me warning treated as error, C4127 - Conditional expression is constant
The fourth parameter expects PVOID and we're passing the null and on the expansion of this macro

    if ( CompRoutine != NULL) {                                          \
        IoSetCompletionRoutine( Irp, CompRoutine, Contxt, TRUE, TRUE, TRUE);\
    } else {                                                             \
        IoSetCompletionRoutine( Irp, NULL, NULL, FALSE, FALSE, FALSE);   \
    }  

NULL!=NULL causing this
Also
in MSDN
" * CompRoutine [in]
Specifies the entry point of a client-supplied IoCompletion routine or NULL. The I/O manager calls this routine when the given IRP is completed, unless the client sets this parameter to NULL. "
To fix this, one workaround can be to surpress the warning,
is their any other solution

const BOOL hasCompRoutine = !!CompRoutine; \
IoSetCompletionRoutine( Irp, CompRoutine, Contxt, hasCompRoutine, hasCompRoutine, hasCompRoutine); \
1 Like

this particular piece of code is from tdikernel.h which is from wdk so cant do any changes in that
also I saw after disabling the warnings, it would show unreachable code error

Going to take a random guess here. Is the compiler misreporting the error and the fix is actually that you are passing FILE_OBJECT and not PFILE_OBJECT?

&WorkThreadCtx->fileobject

I would simply expand the macro manually and insert the resulting code in place of the macro. There must be a macro which pulls WDK version. You can use it to make the manual expansion work only for your current WDK.

Or you can create a dummy completion routine which does nothing.

its PFILE_OBJECT , not FILE_OBJECT