forked from Imagelibrary/rtems
cpukit/libblock: Close all valid FDs
This is intended to close any valid FDs that were opened, but 0 is also a valid FD. This change ensures that a FD of 0 is also closed properly. Coverity CID 1467408 (original) Coverity CID 1616151 (followup) off_by_one: Testing whether handle fd is strictly greater than zero is suspicious. fd leaks when it is zero.
This commit is contained in:
@@ -213,7 +213,7 @@ cleanup:
|
|||||||
* but fd may be -1. Coverity flagged passing a bad value to close().
|
* but fd may be -1. Coverity flagged passing a bad value to close().
|
||||||
*/
|
*/
|
||||||
free( logical_disk_name);
|
free( logical_disk_name);
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
close( fd);
|
close( fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user