Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some constant arrays from data to text section #9187

Merged
merged 2 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] = {
Copy link
Contributor

@potaito potaito Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't constexpr alone instead of const constexpr suffice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case yes. But more is more :D

@[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;
}
2 changes: 1 addition & 1 deletion src/lib/tunes/default_tunes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "tunes.h"

// initialise default tunes
const char *Tunes::_default_tunes[] = {
const char *const Tunes::_default_tunes[] = {
"", // empty to align with the index
"MFT240L8 O4aO5dc O4aO5dc O4aO5dc L16dcdcdcdc", // startup tune
"MBT200a8a8a8PaaaP", // ERROR tone
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tunes/tunes.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Tunes
unsigned int get_maximum_update_interval() {return (unsigned int)TUNE_MAX_UPDATE_INTERVAL_US;}

private:
static const char *_default_tunes[];
static const char *const _default_tunes[];
static const uint8_t _note_tab[];
static const unsigned int _default_tunes_size;
bool _repeat = false; ///< if true, tune restarts at end
Expand Down
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_ */