Skip to content

Refactor FUNCTIONBAR_MAXEVENTS and use sentinels in loops#1910

Open
natoscott wants to merge 1 commit intohtop-dev:mainfrom
natoscott:function-bar-sentinel
Open

Refactor FUNCTIONBAR_MAXEVENTS and use sentinels in loops#1910
natoscott wants to merge 1 commit intohtop-dev:mainfrom
natoscott:function-bar-sentinel

Conversation

@natoscott
Copy link
Member

Set FUNCTIONBAR_MAXEVENTS to the actual limit (11) and adjust the loops which use it to solely rely on sentinel NULL, removing checks for a situation which cannot occur.

Fixes covscan issue #644308

Set FUNCTIONBAR_MAXEVENTS to the actual limit (11) and
adjust the loops which use it to solely rely on sentinel
NULL, removing checks for a situation which cannot occur.

Fixes covscan issue #644308
for (size_t i = 0; i < FUNCTIONBAR_MAXEVENTS && functions[i]; i++) {
for (size_t i = 0; functions[i]; i++) {
this->functions[i] = xStrdup(functions[i]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add an assert here: assert(i <= FUNCTIONBAR_MAXEVENTS);

this->keys.keys[i] = xStrdup(keys[i]);
this->events[i] = events[i];
i++;
i++;
Copy link
Contributor

Choose a reason for hiding this comment

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

This space-to-tab change is probably unintentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments