diff --git a/src/main/core/property-node.c b/src/main/core/property-node.c index ed51dc3..80d965a 100644 --- a/src/main/core/property-node.c +++ b/src/main/core/property-node.c @@ -118,21 +118,6 @@ const char *core_property_node_result_to_str(core_property_node_result_t result) default: return "Undefined error"; } - -void core_property_node_fatal_on_error(core_property_node_result_t result) -{ - switch (result) { - case CORE_PROPERTY_NODE_RESULT_SUCCESS: - return; - case CORE_PROPERTY_NODE_RESULT_ERROR_INTERNAL: - case CORE_PROPERTY_NODE_RESULT_NODE_NOT_FOUND: - default: - log_fatal( - "Operation on property failed: %s", - core_property_node_result_to_str(result)); - } -} - } core_property_node_result_t core_property_node_name_get( diff --git a/src/main/core/property-node.h b/src/main/core/property-node.h index cf35351..fb52028 100644 --- a/src/main/core/property-node.h +++ b/src/main/core/property-node.h @@ -18,6 +18,15 @@ // Guestimate, should be long enough, I hope? #define CORE_PROPERTY_NODE_PATH_LEN_MAX 4096 +// Macro to allow inlining of the caller function and line numbers +// to make debugging easier +#define core_property_node_fatal_on_error(result) \ + if (result != CORE_PROPERTY_NODE_RESULT_SUCCESS) { \ + log_fatal( \ + "Operation on property-node failed: %s", \ + core_property_node_result_to_str(result)); \ + } \ + typedef struct core_property_node core_property_node_t; typedef enum core_property_node_result { @@ -209,7 +218,6 @@ void core_property_node_api_get(core_property_node_api_t *impl); const char * core_property_node_result_to_str(core_property_node_result_t result); -void core_property_node_fatal_on_error(core_property_node_result_t result); core_property_node_result_t core_property_node_name_get( const core_property_node_t *node, char *name, size_t len); diff --git a/src/main/core/property.c b/src/main/core/property.c index 5532b34..7a24353 100644 --- a/src/main/core/property.c +++ b/src/main/core/property.c @@ -91,23 +91,6 @@ const char *core_property_result_to_str(core_property_result_t result) } } -void core_property_fatal_on_error(core_property_result_t result) -{ - switch (result) { - case CORE_PROPERTY_RESULT_SUCCESS: - return; - case CORE_PROPERTY_RESULT_ERROR_INTERNAL: - case CORE_PROPERTY_RESULT_ERROR_ALLOC: - case CORE_PROPERTY_RESULT_NOT_FOUND: - case CORE_PROPERTY_RESULT_ERROR_PERMISSIONS: - case CORE_PROPERTY_RESULT_ERROR_READ: - default: - log_fatal( - "Operation on property failed: %s", - core_property_result_to_str(result)); - } -} - core_property_result_t core_property_create(size_t size, core_property_t **property) { diff --git a/src/main/core/property.h b/src/main/core/property.h index d9962ca..44d3d51 100644 --- a/src/main/core/property.h +++ b/src/main/core/property.h @@ -7,7 +7,14 @@ #include "api/core/log.h" -#define CORE_PROPERTY_RESULT_IS_ERROR(x) (x > CORE_PROPERTY_RESULT_SUCCESS) +// Macro to allow inlining of the caller function and line numbers +// to make debugging easier +#define core_property_fatal_on_error(result) \ + if (result != CORE_PROPERTY_RESULT_SUCCESS) { \ + log_fatal( \ + "Operation on property failed: %s", \ + core_property_result_to_str(result)); \ + } \ typedef struct core_property { // Have size known, but not contents, to allow for stack allocations @@ -65,7 +72,6 @@ void core_property_api_set(const core_property_api_t *api); void core_property_api_get(core_property_api_t *api); const char *core_property_result_to_str(core_property_result_t result); -void core_property_fatal_on_error(core_property_result_t result); core_property_result_t core_property_create(size_t size, core_property_t **property); diff --git a/src/main/launcher/ea3-ident-config.c b/src/main/launcher/ea3-ident-config.c index 822de9e..d27e62d 100644 --- a/src/main/launcher/ea3-ident-config.c +++ b/src/main/launcher/ea3-ident-config.c @@ -27,7 +27,7 @@ static void _ea3_ident_config_root_get( log_assert(node); result = core_property_root_node_get(property, node); - core_property_fatal_on_error(result); + core_property_node_fatal_on_error(result); result = core_property_node_name_get(node, node_name, sizeof(node_name)); core_property_node_fatal_on_error(result); diff --git a/src/main/launcher/launcher.c b/src/main/launcher/launcher.c index ecd1927..7a36b8d 100644 --- a/src/main/launcher/launcher.c +++ b/src/main/launcher/launcher.c @@ -133,7 +133,7 @@ static void _launcher_bootstrap_config_options_override( core_property_free(&config->property); result = core_property_file_load(options->config_path, &config->property); - core_property_node_fatal_on_error(result); + core_property_fatal_on_error(result); } if (options->selector) {