Avviso C6329

Il valore restituito per una chiamata a 'function' non deve essere controllato rispetto a 'number'

Osservazioni:

Il programma sta confrontato un numero con il valore restituito da una chiamata a CreateFile. Se CreateFile viene completato, viene restituito un handle aperto all'oggetto. Se l'operazione ha esito negativo, viene restituito INVALID_HANDLE_VALUE.

Nome dell'analisi del codice: POTENTIAL_INCORRECT_RETVAL_CHECK

Example

Il codice può causare questo avviso:

if (CreateFile() == NULL)
{
  return;
}

Questo codice corregge l'errore:

if (CreateFile() == INVALID_HANDLE_VALUE)
{
  return;
}