Enable cppcoreguidelines check on the repo
This commit adds cppcoreguidelines clang-tidy
checks and make necessary changes.
Change-Id: I402b82f96b7ff82e3ba6d84c9cc50435c1ead6d4
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/.clang-tidy b/.clang-tidy
index b0973f4..cb6b8b3 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -195,6 +195,26 @@
clang-analyzer-valist.ValistBase,
clang-analyzer-webkit.NoUncountedMemberChecker,
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
+cppcoreguidelines-avoid-c-arrays,
+cppcoreguidelines-avoid-goto,
+cppcoreguidelines-avoid-non-const-global-variables,
+cppcoreguidelines-c-copy-assignment-signature,
+cppcoreguidelines-explicit-virtual-functions,
+cppcoreguidelines-init-variables,
+cppcoreguidelines-macro-usage,
+cppcoreguidelines-narrowing-conversions,
+cppcoreguidelines-no-malloc,
+cppcoreguidelines-prefer-member-initializer,
+cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+cppcoreguidelines-pro-bounds-pointer-arithmetic,
+cppcoreguidelines-pro-type-const-cast,
+cppcoreguidelines-pro-type-cstyle-cast,
+cppcoreguidelines-pro-type-member-init,
+cppcoreguidelines-pro-type-reinterpret-cast,
+cppcoreguidelines-pro-type-static-cast-downcast,
+cppcoreguidelines-pro-type-union-access,
+cppcoreguidelines-pro-type-vararg,
+cppcoreguidelines-slicing,
modernize-avoid-bind,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
index ad65777..05068ce 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -65,7 +65,7 @@
elog<InternalFailure>();
}
- sd_event_source* es;
+ sd_event_source* es = nullptr;
r = sd_event_add_io(bus.get_event(), &es, timeFd, EPOLLIN, onTimeChange,
this);
if (r < 0)
diff --git a/test/TestBmcEpoch.cpp b/test/TestBmcEpoch.cpp
index 4d9c814..38cbbaf 100644
--- a/test/TestBmcEpoch.cpp
+++ b/test/TestBmcEpoch.cpp
@@ -18,7 +18,7 @@
public:
sdbusplus::bus_t bus;
Manager manager;
- sd_event* event;
+ sd_event* event = nullptr;
std::unique_ptr<BmcEpoch> bmcEpoch;
TestBmcEpoch() : bus(sdbusplus::bus::new_default()), manager(bus)