Warning C28193

The variable holds a value that must be examined

This warning indicates that the calling function isn't checking the value of the specified variable, which was supplied by a function. The returned value is annotated with the _Check_return_ annotation, but the calling function is either not using the value or is overwriting the value without examining it.

This warning is similar to warning C6031, but it's reported only when the code doesn't test or examine the value of the variable, such as by using it in a comparison. Simply assigning the value isn't considered to be a sufficient examination to avoid this warning. Aliasing the result out of the function is considered a sufficient examination, but the result itself should be annotated with _Check_return_.

Certain functions (such as strlen) exist almost exclusively for their return value, so it makes sense for them to have the _Check_return_ annotation. For these functions, the Code Analysis tool might report this warning when the return value is unused. This warning usually indicates that the code is incorrect, for example, it might contain residual code that could be deleted. However, in some rare instances, the return value is intentionally not used. The most common of these instances is where a string length is returned but not actually used before some other test is made. That other test causes a path to be simulated where the string length ends up being unused. When this happens, the code can be correct, but it might be inefficient.

There are two primary strategies for dealing with these cases where the return value is unused:

Reorder the code so that the string length is only returned along the path where it's needed.

Use a #pragma warning to suppress the warning--if by reordering the code, you would make the code too complex or otherwise less useful.

Example

The following code example generates this warning:

IoGetDmaAdapter(pPDO, &DevDesc, &nMapRegs);
//...

The following code example avoids this warning:

IoGetDmaAdapter(pPDO, &DevDesc, &nMapRegs);
//...
if (nMapRegs < MIN_REQUIRED_MAPS) {
//...
}