From d1836e50fe704509ab9c7624e0e14cbcb484e354 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Thu, 25 Mar 2021 16:16:01 -0700 Subject: [PATCH 1/4] Update c26497.md Adding an explanation that empty/stubbed out functions will not have this warning issued against them in an effort to reduce noise. --- docs/code-quality/c26497.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/code-quality/c26497.md b/docs/code-quality/c26497.md index 6b21f5b6270..0f4829b1218 100644 --- a/docs/code-quality/c26497.md +++ b/docs/code-quality/c26497.md @@ -24,3 +24,12 @@ void function1() noexcept const int theAnswer = GetTheAnswer(0); } ``` + +To reduce noise on new code, this warning will not be issued if the function has an empty implementation. + +```cpp +int function1(){ // no C26497 + return 1; +} +void function2(){} // no C26497 +``` From 29c057c419a7627ca40ccd9f27a2a89284704667 Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 25 Mar 2021 17:31:30 -0700 Subject: [PATCH 2/4] fix github #3056 --- ...strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md b/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md index 51550e7f825..c87054ff448 100644 --- a/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md +++ b/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md @@ -1,7 +1,7 @@ --- description: "Learn more about: strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l" title: "strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l" -ms.date: "4/2/2020" +ms.date: "3/25/2021" api_name: ["_wcsncat_s_l", "wcsncat_s", "_mbsncat_s_l", "_mbsncat_s", "strncat_s", "_strncat_s_l", "_o__mbsncat_s", "_o__mbsncat_s_l", "_o_strncat_s", "_o_wcsncat_s"] api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe", "api-ms-win-crt-private-l1-1-0.dll"] api_type: ["DLLExport"] @@ -145,7 +145,7 @@ strncat_s(dst, _countof(dst), "34567", 3); means that we are asking **strncat_s** to append three characters to two characters in a buffer five characters long; this would leave no space for the null terminator, hence **strncat_s** zeroes out the string and calls the invalid parameter handler. -If truncation behavior is needed, use **_TRUNCATE** or adjust the *size* parameter accordingly: +If truncation behavior is needed, use **_TRUNCATE** or adjust the *count* parameter accordingly: ```C strncat_s(dst, _countof(dst), "34567", _TRUNCATE); From 749c30afec91c4fd172a79d73ff83e3ebc804611 Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 25 Mar 2021 17:38:21 -0700 Subject: [PATCH 3/4] acrolinx --- ...-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md b/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md index c87054ff448..4a7faa8c6e2 100644 --- a/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md +++ b/docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md @@ -133,7 +133,7 @@ Returns 0 if successful, an error code on failure. These functions try to append the first *D* characters of *strSource* to the end of *strDest*, where *D* is the lesser of *count* and the length of *strSource*. If appending those *D* characters will fit within *strDest* (whose size is given as *numberOfElements*) and still leave room for a null terminator, then those characters are appended, starting at the original terminating null of *strDest*, and a new terminating null is appended; otherwise, *strDest*[0] is set to the null character and the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). -There is an exception to the above paragraph. If *count* is [_TRUNCATE](../../c-runtime-library/truncate.md) then as much of *strSource* as will fit is appended to *strDest* while still leaving room to append a terminating null. +There is an exception to the above paragraph. If *count* is [_TRUNCATE](../../c-runtime-library/truncate.md), then as much of *strSource* as will fit is appended to *strDest* while still leaving room to append a terminating null. For example, @@ -143,7 +143,7 @@ strncpy_s(dst, _countof(dst), "12", 2); strncat_s(dst, _countof(dst), "34567", 3); ``` -means that we are asking **strncat_s** to append three characters to two characters in a buffer five characters long; this would leave no space for the null terminator, hence **strncat_s** zeroes out the string and calls the invalid parameter handler. +means that we're asking **strncat_s** to append three characters to two characters in a buffer five characters long; this would leave no space for the null terminator, hence **strncat_s** zeroes out the string and calls the invalid parameter handler. If truncation behavior is needed, use **_TRUNCATE** or adjust the *count* parameter accordingly: @@ -159,11 +159,11 @@ strncat_s(dst, _countof(dst), "34567", _countof(dst)-strlen(dst)-1); In all cases, the resulting string is terminated with a null character. If copying takes place between strings that overlap, the behavior is undefined. -If *strSource* or *strDest* is **NULL**, or is *numberOfElements* is zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md) . If execution is allowed to continue, the function returns **EINVAL** without modifying its parameters. +If *strSource* or *strDest* is **NULL**, or *numberOfElements* is zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md) . If execution is allowed to continue, the function returns **EINVAL** without modifying its parameters. **wcsncat_s** and **_mbsncat_s** are wide-character and multibyte-character versions of **strncat_s**. The string arguments and return value of **wcsncat_s** are wide-character strings; those of **_mbsncat_s** are multibyte-character strings. These three functions behave identically otherwise. -The output value is affected by the setting of the **LC_CTYPE** category setting of the locale; see [setlocale](setlocale-wsetlocale.md) for more information. The versions of these functions without the **_l** suffix use the current locale for this locale-dependent behavior; the versions with the **_l** suffix are identical except that they use the locale parameter passed in instead. For more information, see [Locale](../../c-runtime-library/locale.md). +The output value is affected by the setting of the **LC_CTYPE** category setting of the locale. For more information, see [setlocale](setlocale-wsetlocale.md). The versions of these functions without the **_l** suffix use the current locale for this locale-dependent behavior; the versions with the **_l** suffix are identical except they use the locale parameter passed in instead. For more information, see [Locale](../../c-runtime-library/locale.md). In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically (eliminating the need to specify a size argument) and they can automatically replace older, non-secure functions with their newer, secure counterparts. For more information, see [Secure Template Overloads](../../c-runtime-library/secure-template-overloads.md). @@ -178,7 +178,7 @@ By default, this function's global state is scoped to the application. To change |**_tcsncat_s**|**strncat_s**|**_mbsnbcat_s**|**wcsncat_s**| |**_tcsncat_s_l**|**_strncat_s_l**|**_mbsnbcat_s_l**|**_wcsncat_s_l**| -**_strncat_s_l** and **_wcsncat_s_l** have no locale dependence; they are only provided for **_tcsncat_s_l**. +**_strncat_s_l** and **_wcsncat_s_l** have no locale dependence; they're are only provided for **_tcsncat_s_l**. ## Requirements @@ -188,7 +188,7 @@ By default, this function's global state is scoped to the application. To change |**wcsncat_s**|\ or \| |**_mbsncat_s**, **_mbsncat_s_l**|\| -For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md). +For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md). ## Example From 49d9f06ee4f2761c443f2a393cb9d2e8c4d5cae9 Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Thu, 25 Mar 2021 18:46:08 -0700 Subject: [PATCH 4/4] Make i18n easier. --- docs/code-quality/c26497.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/code-quality/c26497.md b/docs/code-quality/c26497.md index 0f4829b1218..40cb974f201 100644 --- a/docs/code-quality/c26497.md +++ b/docs/code-quality/c26497.md @@ -8,7 +8,7 @@ description: CppCoreCheck rule that enforces C++ Core Guidelines F.4 --- # C26497 USE_CONSTEXPR_FOR_FUNCTION -This function %function% could be marked `constexpr` if compile-time evaluation is desired (f.4). +> This function *function-name* could be marked `constexpr` if compile-time evaluation is desired (f.4). ## See also @@ -25,7 +25,7 @@ void function1() noexcept } ``` -To reduce noise on new code, this warning will not be issued if the function has an empty implementation. +To reduce code analysis noise on new code, this warning isn't issued if the function has an empty implementation. ```cpp int function1(){ // no C26497