Fix static analysis issue 22/242222/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 25 Aug 2020 05:03:51 +0000 (14:03 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 25 Aug 2020 05:03:51 +0000 (14:03 +0900)
Change-Id: Iedeeb275edaa9b09e3a2ff7af88c88b5adfdbfb2
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/utils/user_util.cc

index 93384e6..d030ba4 100644 (file)
@@ -130,9 +130,8 @@ boost::optional<gid_t> GetGidByGroupName(const char* groupname) {
   struct group entry;
   struct group* ge;
   int ret = getgrnam_r(groupname, &entry, buf, sizeof(buf), &ge);
-  if (ret || ge == nullptr) {
-    return result;
-  }
+  if (ret || ge == nullptr)
+    return {};
   result = entry.gr_gid;
   return result;
 }
@@ -164,7 +163,7 @@ boost::optional<gid_t> GetGidByUid(uid_t uid) {
   char buf[kPWBufSize];
   int ret = getpwuid_r(uid, &pwd, buf, sizeof(buf), &pwd_result);
   if (ret != 0 || pwd_result == nullptr)
-    return result;
+    return {};
   result = pwd.pw_gid;
   return result;
 }