Skip to content

Commit

Permalink
uorb: fix constness for _uorb_topics_list
Browse files Browse the repository at this point in the history
_uorb_topics_list was marked as 'const char *' array, which means the data
of the array was not actually const and thus landed in the data section
(so in RAM instead of FLASH).
The size of the array is 436 bytes.
  • Loading branch information
bkueng authored and dagar committed Mar 29, 2018
1 parent 576f4e0 commit 0038a5e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions msg/templates/uorb/uORBTopics.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ msgs_count_all = len(msg_names_all)
@[end for]

const size_t _uorb_topics_count = @(msgs_count_all);
const struct orb_metadata* _uorb_topics_list[_uorb_topics_count] = {
const constexpr struct orb_metadata* const _uorb_topics_list[_uorb_topics_count] = {
@[for idx, msg_name in enumerate(msg_names_all, 1)]@
ORB_ID(@(msg_name))@[if idx != msgs_count_all],@[end if]
@[end for]
Expand All @@ -67,7 +67,7 @@ size_t orb_topics_count()
return _uorb_topics_count;
}

const struct orb_metadata **orb_get_topics()
const struct orb_metadata *const*orb_get_topics()
{
return _uorb_topics_list;
}
6 changes: 3 additions & 3 deletions src/modules/logger/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Logger::Logger(LogWriter::Backend backend, size_t buffer_size, uint32_t log_inte
_sdlog_profile_handle = param_find("SDLOG_PROFILE");

if (poll_topic_name) {
const orb_metadata **topics = orb_get_topics();
const orb_metadata *const*topics = orb_get_topics();

for (size_t i = 0; i < orb_topics_count(); i++) {
if (strcmp(poll_topic_name, topics[i]->o_name) == 0) {
Expand Down Expand Up @@ -478,7 +478,7 @@ LoggerSubscription* Logger::add_topic(const orb_metadata *topic)

bool Logger::add_topic(const char *name, unsigned interval)
{
const orb_metadata **topics = orb_get_topics();
const orb_metadata *const*topics = orb_get_topics();
LoggerSubscription *subscription = nullptr;

for (size_t i = 0; i < orb_topics_count(); i++) {
Expand Down Expand Up @@ -1625,7 +1625,7 @@ void Logger::write_formats()
{
_writer.lock();
ulog_message_format_s msg = {};
const orb_metadata **topics = orb_get_topics();
const orb_metadata *const*topics = orb_get_topics();

//write all known formats
for (size_t i = 0; i < orb_topics_count(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/replay/replay_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ bool Replay::nextDataMessage(std::ifstream &file, Subscription &subscription, in

const orb_metadata *Replay::findTopic(const std::string &name)
{
const orb_metadata **topics = orb_get_topics();
const orb_metadata *const *topics = orb_get_topics();

for (size_t i = 0; i < orb_topics_count(); i++) {
if (name == topics[i]->o_name) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/uORB/uORBTopics.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ extern size_t orb_topics_count() __EXPORT;
/*
* Returns array of topics metadata
*/
extern const struct orb_metadata **orb_get_topics() __EXPORT;
extern const struct orb_metadata *const *orb_get_topics() __EXPORT;

#endif /* MODULES_UORB_UORBTOPICS_H_ */

0 comments on commit 0038a5e

Please sign in to comment.