user_channel: passwd_mgr: minor cleanup from cppcheck
[user_channel/passwd_mgr.cpp:220]: (style) The scope of the
variable 'userEPos' can be reduced.
[user_channel/passwd_mgr.cpp:358]: (style) The scope of the
variable 'userEPos' can be reduced.
[user_channel/passwd_mgr.cpp:444]: (style) Variable 'fd' is
assigned a value that is never used.
Tested: Not tested.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: If02125c422ab1e9c15c6420dbf8da6a52fb68541
diff --git a/user_channel/passwd_mgr.cpp b/user_channel/passwd_mgr.cpp
index 525b2b7..66bdef0 100644
--- a/user_channel/passwd_mgr.cpp
+++ b/user_channel/passwd_mgr.cpp
@@ -217,9 +217,10 @@
char* outPtr = reinterpret_cast<char*>(dataBuf.data());
char* nToken = NULL;
char* linePtr = strtok_r(outPtr, "\n", &nToken);
- size_t userEPos = 0, lineSize = 0;
+ size_t lineSize = 0;
while (linePtr != NULL)
{
+ size_t userEPos = 0;
std::string lineStr(linePtr);
if ((userEPos = lineStr.find(":")) != std::string::npos)
{
@@ -355,11 +356,12 @@
if (inBytesLen != 0)
{
char* outPtr = reinterpret_cast<char*>(dataBuf.data());
- size_t userEPos = 0;
char* nToken = NULL;
char* linePtr = strtok_r(outPtr, "\n", &nToken);
while (linePtr != NULL)
{
+ size_t userEPos = 0;
+
std::string lineStr(linePtr);
if ((userEPos = lineStr.find(":")) != std::string::npos)
{
@@ -441,7 +443,6 @@
log<level::DEBUG>("Error creating temp file");
return -EIO;
}
- fd = -1; // don't use fd anymore, as the File object owns it
// Set the file mode as of actual ipmi-pass file.
if (fchmod(fileno((temp)()), st.st_mode) < 0)