Skip to content

Commit 8a1c95b

Browse files
Updated C28159
Updated to new format, added more details
1 parent 5894896 commit 8a1c95b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/code-quality/c28159.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,44 @@
22
description: "Learn more about: C28159"
33
title: C28159
44
ms.date: 11/04/2016
5+
ms.date: 09/08/2022
56
ms.topic: reference
67
f1_keywords: ["C28159"]
8+
f1_keywords: ["C28159", "USE_OTHER_FUNCTION", "__WARNING_USE_OTHER_FUNCTION"]
79
helpviewer_keywords: ["C28159"]
810
ms.assetid: fab6cd58-0985-4ef6-89a2-64ed04297437
911
---
1012
# C28159
13+
# Warning C28159
1114

1215
> warning C28159: Consider using another function instead.
13-
16+
> Consider using `\**function_name_1*` instead of `\**function_name_2*`. Reason: `\**reason*`
1417
This warning is reported for Drivers is suggesting that you use a preferred function call that is semantically equivalent to the function that the driver is calling. This is a general warning message; the annotation `__drv_preferredFunction` was used (possibly with a conditional a `__drv_when`() annotation) to flag a bad coding practice.
18+
This warning occurs when that you use a function that is semantically equivalent to an alternative, preferred function call.
19+
20+
## Remarks
21+
22+
This is a general warning message; the annotation `__drv_preferredFunction` was used (possibly with a conditional a `__drv_when`() annotation) to flag a bad coding practice.
23+
24+
Code analysis name: USE_OTHER_FUNCTION
1525

1626
## Example
1727

1828
The following code example generates this warning:
29+
The following code example generates this warning. This issue is due to the use of `OemToChar`, which does not validate the buffer size:
1930

2031
```cpp
2132
char buff[MAX_PATH];
22-
2333
// if strlen(input) > MAX_PATH
2434
// leads to buffer overrun
35+
// if strlen(input) > MAX_PATH, this call leads to buffer overrun
2536
OemToChar(buff, input);
2637
```
2738
2839
The following code example avoids this warning:
40+
The following code example avoids this warning by using the recommended alternative `OemToCharBuff`, which takes in the destination buffer size and limits the copy appropriatly:
2941
3042
```cpp
3143
char buff[MAX_PATH];
32-
3344
OemToCharBuff(buff, input, MAX_PATH);
3445
```

0 commit comments

Comments
 (0)