Bug 40789 - fixincludes/fixincl.c: duplicate call to close ?
Summary: fixincludes/fixincl.c: duplicate call to close ?
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-17 19:38 UTC by David Binderman
Modified: 2024-06-07 20:03 UTC (History)
2 users (show)

See Also:
Host: x86_64-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2009-07-17 19:38:22 UTC
I just had a look at source code file fixincludes/fixincl.c

I can see that function test_for_changes makes a call
to close near the end of its definition as follows

  close (read_fd);  /* probably redundant, but I'm paranoid */

But around line 1352 of the same file is what
appears to be a redundant call to close.

        test_for_changes (read_fd);
        close (read_fd);

So there seems to be duplicate calls to close on the same
file descriptor.

Suggest remove the second call to close and re-word
the comment, which appears to be wrong, the close is required.
Comment 1 Eric Gallager 2019-03-28 04:29:29 UTC
did you discover this with cppcheck or by looking manually?
Comment 2 Eric Gallager 2024-06-07 20:03:06 UTC
(In reply to Eric Gallager from comment #1)
> did you discover this with cppcheck or by looking manually?

Also does -fanalyzer catch this?