Skip to content

Fix #1473: warn when fclose() is used as a while loop condition#8444

Open
francois-berder wants to merge 7 commits into
cppcheck-opensource:mainfrom
francois-berder:pr-1473
Open

Fix #1473: warn when fclose() is used as a while loop condition#8444
francois-berder wants to merge 7 commits into
cppcheck-opensource:mainfrom
francois-berder:pr-1473

Conversation

@francois-berder
Copy link
Copy Markdown
Collaborator

Using fclose() as a while loop condition closes the file on every iteration and operates on an already-closed file handle from the second iteration onward.

@sonarqubecloud
Copy link
Copy Markdown

Comment thread test/testio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
Comment thread test/testio.cpp Outdated
Comment thread lib/checkio.cpp Outdated
…oop condition

Using fclose() as a while loop condition closes the file on every
iteration and operates on an already-closed file handle from the
second iteration onward.

Signed-off-by: Francois Berder <fberder@outlook.fr>
…close() is used as a while loop condition
… when fclose() is used as a while loop condition
… warn when fclose() is used as a while loop condition
Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright. Can you please create a checker documentation file in man/checkers for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants