2

I have a function in C, which contains lines below:

while (src=strstr(src,key)) {
        memmove(src,src+strlen(key),1+strlen(src+strlen(key)));
    }

When I run parasoft to check the function, I receive so many errors from these lines:

Not enclosed with brackets assignment was found in 'while' condition expression
LHS operand of '+' operator is 'unsigned long'
LHS operand of '+' operator is 'unsigned long'
LHS operand of '+' operator is 'unsigned long'
RHS operand of '+' operator is 'unsigned long'
RHS operand of '+' operator is 'unsigned long'
RHS operand of '+' operator is 'unsigned long'
Third param to 'memmove' function depends on second: src, key

Do you have any idea where theses errors come from?

Waveter
  • 890
  • 10
  • 22

1 Answers1

1

The first message is because the tool suspects you could have meant:

while (src == strstr(src, key)) {  /* comparison instead of assignment */

To make clear the assignment is intended, some tools expect you to write

while ((src = strstr(src, key))) {
undur_gongor
  • 15,657
  • 5
  • 63
  • 75