clang-tidy: Enable bugprone-narrowing-conversions check

This check indicates instances where there's a potential loss of
data during type conversions, particularly when converting from
a wider type to a narrower type.

Change-Id: I43f3d9ff4a6d672f51c7b2d3eccca90f262fa852
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index cb49236..67e4198 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -23,6 +23,7 @@
 bugprone-misplaced-widening-cast,
 bugprone-move-forwarding-reference,
 bugprone-multiple-statement-macro,
+bugprone-narrowing-conversions,
 bugprone-no-escape,
 bugprone-not-null-terminated-result,
 bugprone-parent-virtual-call,
diff --git a/sync_watch.cpp b/sync_watch.cpp
index 653a22d..fdeace6 100644
--- a/sync_watch.cpp
+++ b/sync_watch.cpp
@@ -114,7 +114,7 @@
         }
 
         // fileMap<wd, path>
-        auto rc = syncWatch->syncCallback(event->mask,
+        auto rc = syncWatch->syncCallback(static_cast<int>(event->mask),
                                           syncWatch->fileMap[event->wd]);
         if (rc)
         {
diff --git a/test/utest.cpp b/test/utest.cpp
index d436179..8f400ff 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -19,6 +19,8 @@
 using namespace phosphor::software::manager;
 using namespace phosphor::software::image;
 
+namespace fs = std::filesystem;
+
 class VersionTest : public testing::Test
 {
   protected:
@@ -355,8 +357,13 @@
     std::string readFile(fs::path path)
     {
         std::ifstream f(path, std::ios::in);
-        const auto sz = fs::file_size(path);
-        std::string result(sz, '\0');
+        if (!f.is_open())
+        {
+            throw "Failed to open file";
+        }
+
+        auto sz = static_cast<std::streamsize>(fs::file_size(path));
+        std::string result(static_cast<size_t>(sz), '\0');
         f.read(result.data(), sz);
 
         return result;