Skip to content

Commit

Permalink
Ada : Fixing cppcheck errors
Browse files Browse the repository at this point in the history
   parsers/ada.c:497:41: style: Condition 'token->prev==NULL' is always true [knownConditionTrueFalse]
   parsers/ada.c:493:20: note: Assuming that condition 'token->prev!=NULL' is not redundant
   parsers/ada.c:497:41: note: Condition 'token->prev==NULL' is always true
   parsers/ada.c:507:41: style: Condition 'token->next==NULL' is always true [knownConditionTrueFalse]
   parsers/ada.c:503:20: note: Assuming that condition 'token->next!=NULL' is not redundant
   parsers/ada.c:507:41: note: Condition 'token->next==NULL' is always true
   parsers/ada.c:2025:19: style: Variable 'token' is reassigned a value before the old one has been used. [redundantAssignment]
  parsers/ada.c:2023:19: note: token is assigned
  parsers/ada.c:2025:19: note: token is overwritten

Following cppcheck error is false error (The function 'skipPastKeywordOrWord' is used)
  parsers/ada.c:944:0: style: The function 'skipPastKeywordOrWord' is never used. [unusedFunction]
koenmeersman committed Apr 7, 2021
1 parent 8933d0f commit 3c1ef3b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions parsers/ada.c
Original file line number Diff line number Diff line change
@@ -494,8 +494,10 @@ static void freeAdaToken(adaTokenList *list, adaTokenInfo *token)
{
token->prev->next = token->next;
}
else if(list != NULL && token->prev == NULL)
else if(list != NULL)
{
/* Token to remove is head in list as 'token->prev == NULL' */
Assert(token->prev == NULL);
list->head = token->next;
}

@@ -504,8 +506,10 @@ static void freeAdaToken(adaTokenList *list, adaTokenInfo *token)
{
token->next->prev = token->prev;
}
else if(list != NULL && token->next == NULL)
else if(list != NULL)
{
/* Token to remove is tail of list as 'token->next == NULL') */
Assert(token->next == NULL);
list->tail = token->prev;
}

@@ -2020,9 +2024,8 @@ static adaTokenInfo *adaParse(adaParseMode mode, adaTokenInfo *parent)
* found, if we didn't just fall through */
if((pos + i) < lineLen)
{
token = newAdaToken(&line[pos], i, ADA_KIND_LABEL, false, parent);
newAdaToken(&line[pos], i, ADA_KIND_LABEL, false, parent);
skipPast(">>");
token = NULL;
}
} /* else if(strncasecmp(line[pos], "<<", strlen("<<")) == 0) */
/* we need to check for a few special case keywords that might cause

0 comments on commit 3c1ef3b

Please sign in to comment.