Skip to content

Commit

Permalink
Remove simplification in combineOperators() (#6900)
Browse files Browse the repository at this point in the history
Caused inconsistent results in
#6889
  • Loading branch information
chrchr-github authored Oct 11, 2024
1 parent 20f8a74 commit 0dbc7c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari

else if (tok3->str() == "}") {
if (indentlevel3 == 0) {
memoryLeak(tok3, variable->name() + "." + tok2->strAt(2), allocType);
memoryLeak(tok3, variable->name() + "." + assignToks.first->str(), allocType);
break;
}
--indentlevel3;
Expand Down
13 changes: 2 additions & 11 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3605,17 +3605,8 @@ void Tokenizer::combineOperators()
tok->deleteNext();
}
} else if (tok->str() == "->") {
// If the preceding sequence is "( & %name% )", replace it by "%name%"
Token *t = tok->tokAt(-4);
if (Token::Match(t, "( & %name% )") && !Token::simpleMatch(t->previous(), ">")) {
t->deleteThis();
t->deleteThis();
t->deleteNext();
tok->str(".");
} else {
tok->str(".");
tok->originalName("->");
}
tok->str(".");
tok->originalName("->");
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/cfg/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ ssize_t nullPointer_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t o
return pwritev(fd,iov,iovcnt,offset);
}

// False negative: #9346
// #9346
void uninitvar_timercmp(struct timeval t)
{
struct timeval uninit;
// cppcheck-suppress uninitvar
(void)timercmp(&t, &uninit, <);
(void)timercmp(&uninit, &t, <=);
(void)timercmp(&uninit, &uninit, ==);
Expand Down

0 comments on commit 0dbc7c8

Please sign in to comment.