I've been modifying some code written by a previous employee and came across a function with the following signature:
BOOL WINAPI PrependPadding( _In_ SIZE_T cbPadding, _In_ SIZE_T cbRow, _Out_writes_bytes_(cbPadding) _On_failure_(_Post_null_) BYTE *bRow )
For those of you unfamiliar with Microsoft's SAL annotation meta-language, the annotations on this function basically state that should the function fail for whatever reason, the pointer
bRow will be
NULL after execution of this function.
I find this interesting because it enforces that the caller must check the return value for success/failure - if you try and do anything with
bRow after this function fails, it will obviously crash.
However, is this generally a good practice? I've never seen this used before and I'm wondering if it's for a reason.