Fix static analysis issue 93/319393/1 tizen
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 22 Oct 2024 11:04:35 +0000 (20:04 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Tue, 22 Oct 2024 11:15:05 +0000 (20:15 +0900)
- Uninitialized scalar variable
- Dereference null return value

Change-Id: I67d21a9aa7cf2926c9bfd1d484eb5d5e7bdbbc65
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
plugin/app2sd/server/app2sd_interface.c
unit-tests/server/test_server.cc

index 548c058..7c93d20 100644 (file)
@@ -1178,7 +1178,6 @@ int app2sd_pre_migrate_legacy(const char *pkgid, uid_t uid)
                }
        } else {
                free(filename);
-               _W("same pkg exists, remove legacy file (%s)", file_path);
 
                ret = snprintf(file_path, sizeof(file_path), "%s/%s", mmc_path, pkgid);
                if (ret < 0 || ret > sizeof(file_path)) {
@@ -1186,6 +1185,7 @@ int app2sd_pre_migrate_legacy(const char *pkgid, uid_t uid)
                        return APP2EXT_ERROR_PKG_EXISTS;
                }
 
+               _W("same pkg exists, remove legacy file (%s)", file_path);
                ret = remove(file_path);
                if (ret < 0)
                        _E("failed to remove, errno(%d)", errno);
index 2a70481..3ef00f5 100644 (file)
@@ -35,6 +35,7 @@ class App2sdEnvironment : public ::testing::Environment {
     int (*dl_main)(int, char**);
     handle_ = dlopen("../plugin/app2sd/app2sd-server", RTLD_LOCAL | RTLD_LAZY);
     dl_main = reinterpret_cast<int (*)(int, char**)>(dlsym(handle_, "main"));
+    ASSERT_NE(dl_main, nullptr);
     dl_main(0, nullptr);
   }