Skip to content

Commit

Permalink
fix Zenoh Config read\check
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowhatter committed Aug 22, 2024
1 parent dfc95ad commit 5ef8a70
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions rmw_zenoh_cpp/src/detail/zenoh_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,13 @@ rmw_ret_t _get_z_config(
"rmw_zenoh_cpp", "Envar %s cannot be read.", envar_name);
return RMW_RET_ERROR;
}
// If the environment variable contains a path to a file, try to read the configuration from it.
if (envar_uri[0] != '\0') {
// If the environment variable is set, try to read the configuration from the file.
zc_config_from_file(config, envar_uri);
configured_uri = envar_uri;
} else {
// If the environment variable is not set use internal configuration
zc_config_from_file(config, default_uri);
configured_uri = default_uri;
}
// Verify that the configuration is valid.
if (!z_config_check(config)) {

// If the environment variable is set, try to read the configuration from the file,
// if the environment variable is not set use internal configuration
configured_uri = envar_uri[0] != '\0' ? envar_uri : default_uri;

// Try to read the configuration
if (zc_config_from_file(config, configured_uri) != Z_OK) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
"Invalid configuration file %s", configured_uri);
Expand Down

0 comments on commit 5ef8a70

Please sign in to comment.