Skip to content

Commit

Permalink
use array siez for constnat
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Mar 5, 2023
1 parent 061a420 commit 6f5c458
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cmnds/cmd_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ const constant_t g_constants[] = {
{"$current", &getCurrent},
{"$power", &getPower},
#endif
{NULL, NULL}
};
static int g_totalConstants = sizeof(g_constants) / sizeof(g_constants[0]);

// tries to expand a given string into a constant
// So, for $CH1 it will set out to given channel value
// For $led_dimmer it will set out to current led_dimmer value
Expand All @@ -242,7 +243,9 @@ const constant_t g_constants[] = {
// Returns false if no constants found
const char *CMD_ExpandConstant(const char *s, const char *stop, float *out) {
const constant_t *var;
for (var = g_constants; var->constantName; ++var) {
int i;
var = g_constants;
for (i = 0; i < g_totalConstants; i++, var++) {
bool bAllowWildCard = strstr(var->constantName, "*");
const char *ret = strCompareBound(s, var->constantName, stop, bAllowWildCard);
if (ret) {
Expand Down

0 comments on commit 6f5c458

Please sign in to comment.