clang-tidy: Enable bugprone-too-small-loop-variable check

This check detects those for loops that have a loop variable
with a “too small” type which means this type can’t represent
all values which are part of the iteration range.

Change-Id: I9052bfd819ab78970b929411a08d77796c353465
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/.clang-tidy b/.clang-tidy
index 3e096c6..f2e1a72 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -41,6 +41,7 @@
 bugprone-swapped-arguments,
 bugprone-terminating-continue,
 bugprone-throw-keyword-missing,
+bugprone-too-small-loop-variable,
 bugprone-undefined-memory-manipulation,
 bugprone-undelegated-constructor,
 bugprone-unhandled-exception-at-new,
diff --git a/host-bmc/dbus_to_event_handler.cpp b/host-bmc/dbus_to_event_handler.cpp
index 9ad607e..3eef16a 100644
--- a/host-bmc/dbus_to_event_handler.cpp
+++ b/host-bmc/dbus_to_event_handler.cpp
@@ -93,7 +93,7 @@
 
     size_t sensorEventSize = PLDM_SENSOR_EVENT_DATA_MIN_LENGTH + 1;
     const auto& [dbusMappings, dbusValMaps] = dbusMaps.at(sensorId);
-    for (uint8_t offset = 0; offset < dbusMappings.size(); ++offset)
+    for (size_t offset = 0; offset < dbusMappings.size(); ++offset)
     {
         std::vector<uint8_t> sensorEventDataVec{};
         sensorEventDataVec.resize(sensorEventSize);
@@ -101,7 +101,7 @@
             sensorEventDataVec.data());
         eventData->sensor_id = sensorId;
         eventData->sensor_event_class_type = PLDM_STATE_SENSOR_STATE;
-        eventData->event_class[0] = offset;
+        eventData->event_class[0] = static_cast<uint8_t>(offset);
         eventData->event_class[1] = PLDM_SENSOR_UNKNOWN;
         eventData->event_class[2] = PLDM_SENSOR_UNKNOWN;