Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR feedback
  • Loading branch information
Rastaban committed Mar 22, 2023
commit 1f9607d51a4bdaebf44a3a057567a4ba31c30ca6
2 changes: 1 addition & 1 deletion docs/code-quality/c28308.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords: ["C28308"]

## Remarks

This warning indicates a `_*_format_strings_param(position)` SAL annotation is specifying an invalid position for the first parameter to the format string. The annotation helps the checker verify `printf` style formatting strings passed to the function. This issue results in other validity checks on the format specifier parameters to fail.
This warning indicates a `_*_format_strings_param(position)` SAL annotation is specifying an invalid position for the first parameter to the format string. The annotation helps the checker verify `printf` style formatting strings passed to the function. Other format string validity checks that rely on this annotation will not run as a result of this warning.

The `_*_format_strings_param(position)` SAL annotation is attached to the formatting string argument. `position` must be in one of these forms:

Expand Down
11 changes: 5 additions & 6 deletions docs/code-quality/c6065.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ helpviewer_keywords: ["C6065"]

This warning indicates that there's a mismatch between the format specifiers in a string and the types of the associated parameters. The format specifier indicates that at least one of the mismatched arguments should be a pointer to a counted string such as `UNICODE_STRING` or `ANSI_STRING` but it not. This defect can cause crashes, buffer overflows, and potentially incorrect output.

To fix this warning, determine if the format specifier or the argument matches the intended behavior and modify the other to match. When modifying the format specifier for a counted string, it's recommended to explicitly use the size prefix such as `%wZ` or `%hZ` rather than `%Z` due to compatibility issues between C runtimes (CRT). For more information on CRT compatibility, see the section on `%Z` in the [format specification documentation](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md).
To fix this warning, determine if the format specifier or the argument matches the intended behavior and modify the other to match. When modifying the format specifier for a counted string, it's recommended to explicitly use the size prefix such as `%wZ` or `%hZ` rather than `%Z` due to compatibility issues between C runtimes (CRT). For more information on CRT compatibility, see the `%Z` row in the [Type field characters documentation](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md#type-field-characters).

Code analysis name: `MISSING_COUNTED_STRING_ARGUMENT_TO_FORMAT_FUNCTION`

Expand All @@ -39,9 +39,8 @@ int PrintDiagnostic(UNICODE_STRING u)

## See also

[Format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[Using the Microsoft C Runtime with User-Mode Drivers and Desktop Apps](/windows-hardware/drivers/develop/using-the-microsoft-c-runtime-with-user-mode-drivers-and-apps.md)\
[sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l](../c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md)\
[UNICODE_STRING](/windows/win32/api/ntdef/ns-ntdef-_unicode_string.md)\
[ANSI_STRING/_STRING](/windows/win32/api/ntdef/ns-ntdef-string.md)\
[format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[`sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l`](../c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md)\
[`UNICODE_STRING`](/windows/win32/api/ntdef/ns-ntdef-_unicode_string.md)\
[`ANSI_STRING/_STRING`](/windows/win32/api/ntdef/ns-ntdef-string.md)\
[C4313](../error-messages/compiler-warnings/compiler-warning-level-1-c4313.md)
2 changes: 1 addition & 1 deletion docs/code-quality/c6270.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords: ["C6270"]

## Remarks

This warning indicates that not enough arguments are provided to match a format string; at least one of the missing arguments is a floating-point number. This defect can lead to crashes, in addition to potentially incorrect output.
This warning indicates that not enough arguments are provided to match a format string. At least one of the missing arguments is a floating-point number. This defect can lead to crashes, in addition to potentially incorrect output.

Code analysis name: `MISSING_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION`

Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6272.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords: ["C6272"]

## Remarks

This warning indicates that the format string specifies that a float is required, for example, a `%f` or `%g` specification for `printf,` but a non-float such as an integer or string is being passed. This defect can lead to crashes, in addition to potentially incorrect output.
This warning indicates that the format string specifies that a float is required. For example, a `%f` or `%g` specification for `printf`, but a non-float such as an integer or string is being passed. This defect can lead to crashes, in addition to potentially incorrect output.

Code analysis name: `NON_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION`

Expand Down
4 changes: 2 additions & 2 deletions docs/code-quality/c6284.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void f()

## See also

[static_cast Operator](../cpp/static-cast-operator.md)\
[sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l](../c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md)\
[`static_cast` Operator](../cpp/static-cast-operator.md)\
[`sprintf_s`, `_sprintf_s_l`, `swprintf_s`, `_swprintf_s_l`](../c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md)\
[C4477](../error-messages/compiler-warnings/C4477.md)\
[C4840](../error-messages/compiler-warnings/compiler-warning-level-4-c4840.md)
6 changes: 3 additions & 3 deletions docs/code-quality/c6302.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords: ["C6302"]

## Remarks

This warning indicates that a format string specifies a wide character string, but is being passed a narrow character string instead. One cause of the warning is from the meaning of `%s` and `%S` changing when used with `printf` or `wprintf`. This defect can lead to crashes, in addition to potentially incorrect output.
This warning indicates that a format string specifies a wide character string, but is being passed a narrow character string instead. One cause of the warning is because the meaning of `%s` and `%S` flip when used with `printf` or `wprintf`. This defect can lead to crashes, in addition to potentially incorrect output.

Code analysis name: `CHAR_WCHAR_ARGUMENT_TO_FORMAT_FUNCTION`

Expand All @@ -27,7 +27,7 @@ void f()
}
```

The following sample code remediates this issue by using `%hs` to specify a single-byte character string. Alternatively it could have switched to `%S`, which is a narrow string when used with `wprintf` like functions. See [Format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md) for more options.
The following sample code remediates this issue by using `%hs` to specify a single-byte character string. Alternatively it could have switched to `%S`, which is a narrow string when used with `wprintf` like functions. See [Format specification syntax: `printf` and `wprintf` functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md#type-field-characters) for more options.

```cpp
void f()
Expand All @@ -39,6 +39,6 @@ void f()

## See also

[Format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[Format specification syntax: `printf` and `wprintf` functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[C4477](../error-messages/compiler-warnings/C4477.md)\
[C6303](./C6303.md)
6 changes: 3 additions & 3 deletions docs/code-quality/c6303.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords: ["C6303"]

## Remarks

This warning indicates that a format string specifies a narrow character string, but is being passed a wide character string instead. One cause of the warning is from the meaning of `%s` and `%S` changing when used with `printf` or `wprintf`. This defect can lead to crashes, in addition to potentially incorrect output.
This warning indicates that a format string specifies a narrow character string, but is being passed a wide character string instead. One cause of the warning is because the meaning of `%s` and `%S` flip when used with `printf` or `wprintf`. This defect can lead to crashes, in addition to potentially incorrect output.

Code analysis name: `WCHAR_CHAR_ARGUMENT_TO_FORMAT_FUNCTION`

Expand All @@ -29,7 +29,7 @@ void f()
}
```

The following sample code remediates this issue by using `%ls` to specify a wide character string. Alternatively it could have switched to `%S`, which is a wide string when used with `printf` like functions. See [Format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md) for more options.
The following sample code remediates this issue by using `%ls` to specify a wide character string. Alternatively it could have switched to `%S`, which is a wide string when used with `printf` like functions. See [Format specification syntax: `printf` and `wprintf` functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md#type-field-characters) for more options.

```cpp
#include <stdio.h>
Expand All @@ -43,6 +43,6 @@ void f()

## See also

[Format specification syntax: printf and wprintf functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[Format specification syntax: `printf` and `wprintf` functions](../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md)\
[C4477](../error-messages/compiler-warnings/C4477.md)\
[C6302](./C6302.md)