clang-tidy: Enable bugprone-string-literal-with-embedded-nul check
This check finds occurrences of string literal with embedded NUL
character and validates their usage.
The check is ignored on the line because the test case has a
requirement to verify if the NUL terminator is removed or not
by the method.
Change-Id: I919bfed7d9c0b3a43933621bda32cd31c876ff02
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index f2e1a72..5b44e8d 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -32,6 +32,7 @@
bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-string-integer-assignment,
+bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-include,
bugprone-suspicious-memset-usage,
diff --git a/common/test/pldm_utils_test.cpp b/common/test/pldm_utils_test.cpp
index bab64fc..545e542 100644
--- a/common/test/pldm_utils_test.cpp
+++ b/common/test/pldm_utils_test.cpp
@@ -1085,7 +1085,7 @@
std::string_view expectedName = "Name_with__space";
std::string_view result = trimNameForDbus(name);
EXPECT_EQ(expectedName, result);
- name = "Name 1\0";
+ name = "Name 1\0"; // NOLINT(bugprone-string-literal-with-embedded-nul)
expectedName = "Name_1";
result = trimNameForDbus(name);
EXPECT_EQ(expectedName, result);