PengZheng commented on code in PR #779: URL: https://github.com/apache/celix/pull/779#discussion_r1912012279
########## libs/framework/src/celix_bundle_archive.c: ########## @@ -288,206 +284,94 @@ celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *arc } while (0); } if (status != CELIX_SUCCESS) { - error = "Failed to setup archive paths."; - goto init_failed; + fw_log(fw->logger, CELIX_LOG_LEVEL_ERROR, "Failed to create bundle archive; Out of memory."); Review Comment: Memory leaks. ########## libs/framework/src/celix_bundle_archive.c: ########## @@ -288,206 +284,94 @@ celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *arc } while (0); } if (status != CELIX_SUCCESS) { - error = "Failed to setup archive paths."; - goto init_failed; + fw_log(fw->logger, CELIX_LOG_LEVEL_ERROR, "Failed to create bundle archive; Out of memory."); + return status; } - celix_bundle_manifest_t* manifest = NULL; if (isFrameworkBundle) { - status = celix_bundleManifest_createFrameworkManifest(&manifest); + status = celix_bundleManifest_createFrameworkManifest(&archive->manifest); } else { - status = celix_bundleArchive_createCacheDirectory(archive, &manifest); + status = celix_bundleArchive_createCacheDirectory(archive, &archive->manifest); } if (status != CELIX_SUCCESS) { - error = "Failed to initialize archive or create manifest."; - goto dir_failed; - } - - status = celix_bundleRevision_create(fw, archive->archiveRoot, archive->location, manifest, &archive->revision); - if (status != CELIX_SUCCESS) { - error = "Could not create bundle revision."; - goto revision_failed; + fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to create bundle archive."); + if (!isFrameworkBundle) { + celix_utils_deleteDirectory(archive->archiveRoot, NULL); + } + return status; Review Comment: Other resource leaks. ########## libs/framework/src/celix_bundle_archive.c: ########## @@ -288,206 +284,94 @@ celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *arc } while (0); } if (status != CELIX_SUCCESS) { - error = "Failed to setup archive paths."; - goto init_failed; + fw_log(fw->logger, CELIX_LOG_LEVEL_ERROR, "Failed to create bundle archive; Out of memory."); + return status; } - celix_bundle_manifest_t* manifest = NULL; if (isFrameworkBundle) { - status = celix_bundleManifest_createFrameworkManifest(&manifest); + status = celix_bundleManifest_createFrameworkManifest(&archive->manifest); } else { - status = celix_bundleArchive_createCacheDirectory(archive, &manifest); + status = celix_bundleArchive_createCacheDirectory(archive, &archive->manifest); } if (status != CELIX_SUCCESS) { - error = "Failed to initialize archive or create manifest."; - goto dir_failed; - } - - status = celix_bundleRevision_create(fw, archive->archiveRoot, archive->location, manifest, &archive->revision); - if (status != CELIX_SUCCESS) { - error = "Could not create bundle revision."; - goto revision_failed; + fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to create bundle archive."); + if (!isFrameworkBundle) { + celix_utils_deleteDirectory(archive->archiveRoot, NULL); + } + return status; } if (!isFrameworkBundle) { status = celix_bundleArchive_storeBundleStateProperties(archive); if (status != CELIX_SUCCESS) { - error = "Could not store properties."; - goto store_prop_failed; + fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to store bundle state properties."); Review Comment: Directory left, various resource leaks. The previous structured goto can not be removed directly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org