From e71f32d3d03673f13d8cd50d6d7add7fa4d62402 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 22 Oct 2024 20:04:35 +0900 Subject: [PATCH] Fix static analysis issue - Uninitialized scalar variable - Dereference null return value Change-Id: I67d21a9aa7cf2926c9bfd1d484eb5d5e7bdbbc65 Signed-off-by: Ilho Kim --- plugin/app2sd/server/app2sd_interface.c | 2 +- unit-tests/server/test_server.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/app2sd/server/app2sd_interface.c b/plugin/app2sd/server/app2sd_interface.c index 548c058..7c93d20 100644 --- a/plugin/app2sd/server/app2sd_interface.c +++ b/plugin/app2sd/server/app2sd_interface.c @@ -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); diff --git a/unit-tests/server/test_server.cc b/unit-tests/server/test_server.cc index 2a70481..3ef00f5 100644 --- a/unit-tests/server/test_server.cc +++ b/unit-tests/server/test_server.cc @@ -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(dlsym(handle_, "main")); + ASSERT_NE(dl_main, nullptr); dl_main(0, nullptr); } -- 2.7.4