diff options
author | Patrick Venture <venture@google.com> | 2019-08-19 11:19:19 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-08-20 08:55:01 -0700 |
commit | 51d0c40ad6c9181a172fb1fc14aa8d39b66e7ba7 (patch) | |
tree | 7920bf05d8a8272d27fdeb39a9b7a98c76536637 /user_channel/passwd_mgr.cpp | |
parent | 3a697ade9519b2ac5ad61fe218f38f5136263185 (diff) | |
download | phosphor-host-ipmid-51d0c40ad6c9181a172fb1fc14aa8d39b66e7ba7.tar.gz phosphor-host-ipmid-51d0c40ad6c9181a172fb1fc14aa8d39b66e7ba7.zip |
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
Diffstat (limited to 'user_channel/passwd_mgr.cpp')
-rw-r--r-- | user_channel/passwd_mgr.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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 @@ void PasswdMgr::initPasswordMap(void) 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 @@ int PasswdMgr::updatePasswdSpecialFile(const std::string& userName, 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 @@ int PasswdMgr::updatePasswdSpecialFile(const std::string& userName, 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) |