File pacemaker-cib-avoid-unnecessary-memory-allocation.patch of Package pacemaker.14737
commit a24717380b669c56bed84824ab67ad7c7c36ec6a
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Thu Jun 22 15:32:04 2017 -0500
Low: cib: avoid unnecessary memory allocation
diff --git a/cib/main.c b/cib/main.c
index 820692ecb..b8af86e66 100644
--- a/cib/main.c
+++ b/cib/main.c
@@ -215,25 +215,17 @@ main(int argc, char **argv)
}
crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE);
- if (cib_root == NULL) {
- char *path = crm_strdup_printf("%s/cib.xml", CRM_CONFIG_DIR);
- char *legacy = crm_strdup_printf("%s/cib.xml", CRM_LEGACY_CONFIG_DIR);
- if (g_file_test(path, G_FILE_TEST_EXISTS)) {
- cib_root = CRM_CONFIG_DIR;
+ if (cib_root == NULL) {
+ if ((g_file_test(CRM_CONFIG_DIR "/cib.xml", G_FILE_TEST_EXISTS) == FALSE)
+ && (g_file_test(CRM_LEGACY_CONFIG_DIR "/cib.xml", G_FILE_TEST_EXISTS) == TRUE)) {
- } else if (g_file_test(legacy, G_FILE_TEST_EXISTS)) {
+ crm_notice("Using legacy config location: " CRM_LEGACY_CONFIG_DIR);
cib_root = CRM_LEGACY_CONFIG_DIR;
- crm_notice("Using legacy config location: %s", cib_root);
} else {
cib_root = CRM_CONFIG_DIR;
- crm_notice("Using new config location: %s", cib_root);
}
-
- free(legacy);
- free(path);
-
} else {
crm_notice("Using custom config location: %s", cib_root);
}