Skip to content

Commit

Permalink
RDKBDEV-3078: minor code cleanup of boolean parsing (#246)
Browse files Browse the repository at this point in the history
Reason for change:
minor code cleanup of boolean parsing in rbusValue_SetFromString()
Testing a string's prefix and length is equivalent to testing the
entire string.
Test Procedure: Sanity.
Risks: None.
Signed-off-by: Andre McCurdy <[email protected]>

Co-authored-by: Andre McCurdy <[email protected]>
  • Loading branch information
pradeeptakdas and armcc authored Feb 12, 2025
1 parent 51b8773 commit ab1126f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/rbus/rbus_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,9 @@ bool rbusValue_SetFromString(rbusValue_t value, rbusValueType_t type, const char
rbusValue_SetBytes(value,(uint8_t const*)pStringInput,tmp_strlen);
break;
case RBUS_BOOLEAN:
tmp_strlen = strlen(pStringInput);
if (((0 == strncasecmp("true", pStringInput, 4)) && (tmp_strlen == 4)) || ((0 == strncasecmp("1", pStringInput, 1)) && (tmp_strlen == 1)))
if ((strcasecmp(pStringInput, "true") == 0) || (strcmp(pStringInput, "1") == 0))
tmpB = true;
else if (((0 == strncasecmp("false", pStringInput, 5)) && (tmp_strlen == 5)) || ((0 == strncasecmp("0", pStringInput, 1)) && (tmp_strlen == 1)))
else if ((strcasecmp(pStringInput, "false") == 0) || (strcmp(pStringInput, "0") == 0))
tmpB = false;
else
{
Expand Down

0 comments on commit ab1126f

Please sign in to comment.