Fix the bugs found in static analysis
This commit fixes the following static analyzer reported issues:
Operands don't affect result
some conditions are not required to check as its always true
Unsigned compared against 0
Unchecked return value from library
Uninitialized scalar variable
Change-Id: I0b1fd426794bb88f6eafcc817cef5dd2f655e1ba
Signed-off-by: PavanKumarIntel <pavanx.kumar.martha@intel.com>
diff --git a/user_channel/passwd_mgr.cpp b/user_channel/passwd_mgr.cpp
index 7b5b7ec..acf7c74 100644
--- a/user_channel/passwd_mgr.cpp
+++ b/user_channel/passwd_mgr.cpp
@@ -75,7 +75,10 @@
{
if ((st.st_mode & modeMask) != (S_IRUSR | S_IWUSR))
{
- chmod(passwdFileName, S_IRUSR | S_IWUSR);
+ if (chmod(passwdFileName, S_IRUSR | S_IWUSR) == -1)
+ {
+ log<level::DEBUG>("Error setting chmod for ipmi_pass file");
+ }
}
}
@@ -83,7 +86,10 @@
{
if ((st.st_mode & modeMask) != (S_IRUSR | S_IWUSR))
{
- chmod(encryptKeyFileName, S_IRUSR | S_IWUSR);
+ if (chmod(encryptKeyFileName, S_IRUSR | S_IWUSR) == -1)
+ {
+ log<level::DEBUG>("Error setting chmod for ipmi_pass file");
+ }
}
}
}