C28205

warning C28205: function> : _Success_ or _On_failure_ used in an illegal context

The _Success_ and _On_failure_ annotations can only be used on function return values.

Examples

#include<sal.h>

// Oops, _Success_ is not valid in parameter lists, should be moved to return value.
bool GetValue( _Success_(return != false) _Out_ int *pInt, bool flag)
{
   if(flag) {
      *pInt = 5;
      return true;
   } else {
      return false;
   }
}
#include<sal.h>

_Success_(return != false)
bool GetValue(_Out_ int *pInt, bool flag)
{
   if(flag) {
      *pInt = 5;
      return true;
   } else {
      return false;
   }
}

Understanding Sal