Skip to content

Commit c2d1c13

Browse files
Updated C28285
Updated to the new format
1 parent 911222a commit c2d1c13

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

docs/code-quality/c28285.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
---
22
description: "Learn more about: C28285"
33
title: C28285
4-
ms.date: 12/17/2019
4+
ms.date: 09/22/2022
55
ms.topic: reference
6-
f1_keywords: ["C28285"]
6+
f1_keywords: ["C28285", "SPEC_INVALID_SYNTAX2", "__WARNING_SPEC_INVALID_SYNTAX2"]
77
helpviewer_keywords: ["C28285"]
88
ms.assetid: 6197eb0f-7e1e-4c3e-b097-1f6481405994
99
---
10-
# C28285
10+
# Warning C28285
1111

12-
> warning C28285: For function 'function_name', syntax error in 'annotation'
12+
> For function '*function-name*', syntax error in '*annotation*'
1313
14-
The Code Analysis tool reports this warning for syntax errors in the SAL annotation. The SAL parser will recover by discarding the malformed annotation.
14+
## Remarks
15+
16+
The Code Analysis tool reports this warning for syntax errors in the SAL annotation. The SAL parser will recover by discarding the malformed annotation. Double check the documentation for the SAL annotations being used and try to simplify the annotation. You should not use implementation layer annotations such as `__declspec("SAL_begin")` directly. If you are using that layer then change them into higher layers such as `_In_`/`_Out_`/`_Ret_`. See [Annotating Function Parameters and Return Values](annotating-function-parameters-and-return-values.md) for more information.
1517

1618
## Example
1719

20+
The following code generates this warning. The argument `(2,n)` is malformed and will cause a C28285 warning after the _Out_writes_z_ macro is expanded.
21+
1822
```cpp
19-
// The argument '(n,2)' is malformed and will cause a C28285 warning after the _Out_writes_z_ macro is expanded.
2023
void example_func(_Out_writes_z_((2,n)) char* buffer, int n)
2124
{
22-
// ...
23-
buffer[n] = '\0';
25+
buffer[n] = '\0';
2426
}
2527
```
2628
27-
Double check the documentation to the SAL annotations being used and try to simplify the annotation. You should not use implementation layer annotations such as `__declspec("SAL_begin")` directly. If you are using that layer then change them into higher layers such as `_In_`/`_Out_`/`_Ret_`. See [Annotating Function Parameters and Return Values](annotating-function-parameters-and-return-values.md) for more information.
29+
The following code remediates this warning by correcting the malformed annotation
2830
2931
```cpp
3032
void example_func(_Out_writes_z_(n) char* buffer, int n)
3133
{
32-
// ...
33-
buffer[n] = '\0';
34+
buffer[n] = '\0';
3435
}
3536
```
37+

0 commit comments

Comments
 (0)