diff --git a/Tools/zenoh/templates/zenoh/uorb_pubsub_factory.hpp.em b/Tools/zenoh/templates/zenoh/uorb_pubsub_factory.hpp.em index 68638831e05..e8ed30bbb7a 100644 --- a/Tools/zenoh/templates/zenoh/uorb_pubsub_factory.hpp.em +++ b/Tools/zenoh/templates/zenoh/uorb_pubsub_factory.hpp.em @@ -83,10 +83,10 @@ type_topic_count = len(datatypes_with_topics[topic_name]) #endif @[end for] -#define ZENOH_PUBSUB_COUNT \ +#define ZENOH_PUBSUB_COUNT ( \ @[for idx, topic_name in enumerate(datatypes)]@ CONFIG_ZENOH_PUBSUB_@(topic_name.upper())_COUNT + \ -@[end for] 0 +@[end for] 0) @[for topic_name, rihs01_hash in rihs01_hashes.items()]@ const uint8_t @(topic_name)_hash[32] = @(rihs01_hash) @@ -140,7 +140,7 @@ uORB_Zenoh_Publisher* genPublisher(const orb_metadata *meta, int instance) { } } } - return NULL; + return nullptr; } @@ -152,7 +152,7 @@ uORB_Zenoh_Publisher* genPublisher(const char *name, int instance) { } } } - return NULL; + return nullptr; } @@ -164,7 +164,7 @@ Zenoh_Subscriber* genSubscriber(const orb_metadata *meta, int instance) { } } } - return NULL; + return nullptr; } @@ -176,7 +176,7 @@ Zenoh_Subscriber* genSubscriber(const char *name, int instance) { } } } - return NULL; + return nullptr; } const char* getTypeName(const char *name) { @@ -187,7 +187,7 @@ const char* getTypeName(const char *name) { } } } - return NULL; + return nullptr; } @@ -199,7 +199,7 @@ const uint8_t* getRIHS01_Hash(const orb_metadata *meta) { } } } - return NULL; + return nullptr; } const uint8_t* getRIHS01_Hash(const char *name) { @@ -210,5 +210,5 @@ const uint8_t* getRIHS01_Hash(const char *name) { } } } - return NULL; + return nullptr; } diff --git a/src/modules/zenoh/CMakeLists.txt b/src/modules/zenoh/CMakeLists.txt index 60ae506dad0..9e576d17871 100644 --- a/src/modules/zenoh/CMakeLists.txt +++ b/src/modules/zenoh/CMakeLists.txt @@ -75,7 +75,8 @@ target_compile_options(zenohpico_static PUBLIC -Wno-cast-align -Wno-unused-variable -Wno-maybe-uninitialized -Wno-conversion - -Wno-float-equal) + -Wno-float-equal + -Wno-missing-braces) target_compile_options(zenohpico_static PRIVATE -Wno-missing-prototypes -Wno-return-type) # false positive at -O0 (sanitizer builds) diff --git a/src/modules/zenoh/publishers/uorb_publisher.hpp b/src/modules/zenoh/publishers/uorb_publisher.hpp index a29332838d4..3a50238ad0c 100644 --- a/src/modules/zenoh/publishers/uorb_publisher.hpp +++ b/src/modules/zenoh/publishers/uorb_publisher.hpp @@ -103,7 +103,7 @@ public: pfd->events = POLLIN; } - void print() + void print() override { printf("uORB %s -> ", _uorb_meta->o_name); Zenoh_Publisher::print(); diff --git a/src/modules/zenoh/publishers/zenoh_publisher.cpp b/src/modules/zenoh/publishers/zenoh_publisher.cpp index aef04f58230..a72c2c1d714 100644 --- a/src/modules/zenoh/publishers/zenoh_publisher.cpp +++ b/src/modules/zenoh/publishers/zenoh_publisher.cpp @@ -112,7 +112,7 @@ void Zenoh_Publisher::print() { const z_loaned_keyexpr_t *ke = z_publisher_keyexpr(z_loan(_pub)); - if (ke == NULL) { + if (ke == nullptr) { printf("Topic: (unavailable)\n"); return; } diff --git a/src/modules/zenoh/subscribers/zenoh_subscriber.cpp b/src/modules/zenoh/subscribers/zenoh_subscriber.cpp index 00db7a54f33..47733906eb4 100644 --- a/src/modules/zenoh/subscribers/zenoh_subscriber.cpp +++ b/src/modules/zenoh/subscribers/zenoh_subscriber.cpp @@ -72,12 +72,12 @@ int Zenoh_Subscriber::undeclare_subscriber() int Zenoh_Subscriber::declare_subscriber(z_owned_session_t s, const char *keyexpr) { z_owned_closure_sample_t callback; - z_closure(&callback, data_handler_cb, NULL, this); + z_closure(&callback, data_handler_cb, nullptr, this); z_view_keyexpr_t ke; z_view_keyexpr_from_str(&ke, keyexpr); - if (z_declare_subscriber(z_loan(s), &_sub, z_loan(ke), z_closure_sample_move(&callback), NULL) < 0) { + if (z_declare_subscriber(z_loan(s), &_sub, z_loan(ke), z_closure_sample_move(&callback), nullptr) < 0) { printf("Unable to declare subscriber.\n"); exit(-1); } @@ -96,7 +96,7 @@ void Zenoh_Subscriber::print(const char *type_string, const char *topic_string) { const z_loaned_keyexpr_t *ke = z_subscriber_keyexpr(z_loan(_sub)); - if (ke == NULL) { + if (ke == nullptr) { printf("Topic: (unavailable) -> %s %s\n", type_string, topic_string); return; } diff --git a/src/modules/zenoh/zenoh.cpp b/src/modules/zenoh/zenoh.cpp index 8491de1e2d9..6c3fedde76b 100644 --- a/src/modules/zenoh/zenoh.cpp +++ b/src/modules/zenoh/zenoh.cpp @@ -325,10 +325,10 @@ int ZENOH::setupSession() sleep(5); // Wait 5 seconds when doing a retry } - } while ((ret = z_open(&_s, z_move(config), NULL)) < 0); + } while ((ret = z_open(&_s, z_move(config), nullptr)) < 0); // Start read and lease tasks for zenoh-pico - if (zp_start_read_task(z_loan_mut(_s), NULL) < 0 || zp_start_lease_task(z_loan_mut(_s), NULL) < 0) { + if (zp_start_read_task(z_loan_mut(_s), nullptr) < 0 || zp_start_lease_task(z_loan_mut(_s), nullptr) < 0) { PX4_ERR("Unable to start read and lease tasks"); ret = -EINVAL; } @@ -364,7 +364,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) z_owned_liveliness_token_t token; - if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), NULL) < 0) { + if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), nullptr) < 0) { PX4_ERR("Unable to create liveliness token!\n"); return -1; } @@ -390,7 +390,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) _zenoh_subscribers[i] = genSubscriber(type, instance_no); const uint8_t *rihs_hash = getRIHS01_Hash(type); - if (rihs_hash != NULL && _zenoh_subscribers[i] != 0 && + if (rihs_hash != nullptr && _zenoh_subscribers[i] != nullptr && generate_rmw_zenoh_topic_keyexpr(topic, rihs_hash, type, keyexpr) > 0) { _zenoh_subscribers[i]->declare_subscriber(_s, keyexpr); #ifdef CONFIG_ZENOH_RMW_LIVELINESS @@ -405,7 +405,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) z_owned_liveliness_token_t token; - if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), NULL) < 0) { + if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), nullptr) < 0) { PX4_ERR("Unable to create liveliness token!\n"); return -1; } @@ -414,12 +414,12 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #endif } else { - _zenoh_subscribers[i] = NULL; + _zenoh_subscribers[i] = nullptr; PX4_ERR("Could not create a subscriber for type %s", type); } } else { - _zenoh_subscribers[i] = NULL; + _zenoh_subscribers[i] = nullptr; PX4_ERR("Error parsing publisher config at index %i", i); } } @@ -470,7 +470,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) _zenoh_publishers[i] = genPublisher(type, instance); const uint8_t *rihs_hash = getRIHS01_Hash(type); - if (rihs_hash && _zenoh_publishers[i] != 0 && + if (rihs_hash && _zenoh_publishers[i] != nullptr && generate_rmw_zenoh_topic_keyexpr(topic, rihs_hash, type, keyexpr) > 0) { #ifdef CONFIG_ZENOH_PUB_OPTION_OVERRIDE _zenoh_publishers[i]->declare_publisher(_s, keyexpr, (uint8_t *)&_px4_guid, &pub_opts); @@ -490,7 +490,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) z_owned_liveliness_token_t token; - if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), NULL) < 0) { + if (z_liveliness_declare_token(z_loan(_s), &token, z_loan(ke), nullptr) < 0) { PX4_ERR("Unable to create liveliness token!\n"); return -1; } @@ -499,12 +499,12 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #endif } else { - _zenoh_publishers[i] = NULL; + _zenoh_publishers[i] = nullptr; PX4_ERR("Could not create a publisher for type %s", type); } } else { - _zenoh_publishers[i] = NULL; + _zenoh_publishers[i] = nullptr; PX4_ERR("Error parsing publisher config at index %i", i); } } diff --git a/src/modules/zenoh/zenoh.h b/src/modules/zenoh/zenoh.h index efc30b15ff7..fdb38aa9d76 100644 --- a/src/modules/zenoh/zenoh.h +++ b/src/modules/zenoh/zenoh.h @@ -74,7 +74,7 @@ public: /** * @see ModuleBase::print_usage */ - int print_status(); + int print_status() override; /** * @see ModuleBase::task_spawn diff --git a/src/modules/zenoh/zenoh_config.cpp b/src/modules/zenoh/zenoh_config.cpp index cbdeff91ca7..0963cb08ee0 100644 --- a/src/modules/zenoh/zenoh_config.cpp +++ b/src/modules/zenoh/zenoh_config.cpp @@ -62,7 +62,7 @@ Zenoh_Config::Zenoh_Config() { bool correct_config = true; DIR *dir = opendir(ZENOH_ROOT_PATH); - fp_mapping = NULL; + fp_mapping = nullptr; if (dir) { /* Directory exists. */ @@ -90,7 +90,7 @@ Zenoh_Config::Zenoh_Config() Zenoh_Config::~Zenoh_Config() { - if (fp_mapping != NULL) { + if (fp_mapping != nullptr) { fclose(fp_mapping); } } @@ -120,7 +120,7 @@ int Zenoh_Config::AddPubSub(char *topic, char *datatype, int instance_no, const for (size_t i = 0; i < orb_topics_count(); i++) { const struct orb_metadata *meta = get_orb_meta((ORB_ID)i); - if (meta != NULL && + if (meta != nullptr && strcmp(meta->o_name, datatype) == 0) { FILE *fp = fopen(filename, "a"); @@ -232,7 +232,7 @@ int Zenoh_Config::SetNetworkConfig(char *mode, char *locator) FILE *fp = fopen(ZENOH_NET_CONFIG_PATH, "w"); if (fp) { - if (locator == 0) { + if (locator == nullptr) { fprintf(fp, "%s\n", mode); } else { @@ -265,7 +265,7 @@ int Zenoh_Config::cli(int argc, char *argv[]) } else if (argc == 3) { if (strcmp(argv[1], "net") == 0) { - SetNetworkConfig(argv[2], 0); + SetNetworkConfig(argv[2], nullptr); } else if (strcmp(argv[1], "delete") == 0) { printf("The name of the resource to be deleted needs to be specified.\n"); @@ -427,7 +427,7 @@ int Zenoh_Config::parse_csv_line(char *line, const char **fields, int max_fields fields[field_count] = token; field_count++; - token = strtok(NULL, ";\n\r"); + token = strtok(nullptr, ";\n\r"); } return field_count; @@ -512,10 +512,10 @@ int Zenoh_Config::getLineCount(const char *filename) int Zenoh_Config::closePubSubMapping() { - if (fp_mapping != NULL) { + if (fp_mapping != nullptr) { //Close the file fclose(fp_mapping); - fp_mapping = NULL; + fp_mapping = nullptr; return 0; } @@ -647,12 +647,12 @@ int Zenoh_Config::getPubSubMapping(char *topic, char *type, int *instance, const char buffer[MAX_LINE_SIZE]; - if (fp_mapping == NULL) { + if (fp_mapping == nullptr) { fp_mapping = fopen(filename, "r"); } if (fp_mapping) { - while (fgets(buffer, MAX_LINE_SIZE, fp_mapping) != NULL) { + while (fgets(buffer, MAX_LINE_SIZE, fp_mapping) != nullptr) { if (buffer[0] != '\n') { #ifdef CONFIG_ZENOH_PUB_OPTION_OVERRIDE