Re: [PATCH] Check 'fd' neither -1 nor 0, before close it

2014-11-18 Thread Chen Gang
On 11/18/14 0:38, Joseph Myers wrote: On Sat, 15 Nov 2014, Chen Gang wrote: Also in c_common_read_pch(), when failure occurs, also need be sure the 'fd' is not '-1' for the next close operation. Please clarify how c_common_read_pch gets called with fd == -1. Certainly checking after an

Re: [PATCH] Check 'fd' neither -1 nor 0, before close it

2014-11-17 Thread Joseph Myers
On Sat, 15 Nov 2014, Chen Gang wrote: Also in c_common_read_pch(), when failure occurs, also need be sure the 'fd' is not '-1' for the next close operation. Please clarify how c_common_read_pch gets called with fd == -1. Certainly checking after an error is too late; we shouldn't call fdopen

[PATCH] Check 'fd' neither -1 nor 0, before close it

2014-11-15 Thread Chen Gang
'fd' may be 0 which does not need 'open' operation, so neither need 'close' operation on it when it is 0. Also in c_common_read_pch(), when failure occurs, also need be sure the 'fd' is not '-1' for the next close operation. It passes testsuite under Fedora x86_64-unknown-linux-gnu. gcc/