Skip to content

Commit 5db5c1e

Browse files
TylerMSFTTylerMSFT
authored andcommitted
go with _Out_opt_ and annotate the sample with why
1 parent 0ba9581 commit 5db5c1e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/code-quality/best-practices-and-examples-sal.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ void Func1(_In_ int *p1)
2525
}
2626

2727
// Correct
28-
void Func2(_Out_ PCHAR p1)
28+
// _Out_opt_ because the function tolerates NULL as a valid argument, i.e.
29+
// no error is returned. If the function didn't check p1 for NULL, then
30+
// _Out_ would be the better choice
31+
void Func2(_Out_opt_ PCHAR p1)
2932
{
3033
if (p1 == NULL)
3134
return;

0 commit comments

Comments
 (0)