Hi Jan and Cyril, Thanks for your question and suggestion;) What I mean is that: 1. errno will be set to negative when someone function run failed, but it will not be set back to 0 when someone function return 0. 2. Usually we use *errno* after someone function(Eg: read()) return negative. But if we want to use errno after read() return 0, we should set errno to 0 before call read(), or if read() return >=0, the errno maybe keep using last failed number which setted by someone earlier function than read().
Acccording to above, I checked all code in testcases/kernel/io/direct_io/, make sure all errno be setted to 0 before use errno in *if return success* condition. If you feel this patch is OK, I will send another email with clear commit message which you suggested. Thank you, Zorro Lang ----- 原始邮件 ----- > 发件人: "Jan Stancek" <jstan...@redhat.com> > 收件人: "Cyril Hrubis" <chru...@suse.cz> > 抄送: "Zorro Lang" <zl...@redhat.com>, ltp-list@lists.sourceforge.net > 发送时间: 星期一, 2014年 12 月 08日 下午 8:03:13 > 主题: Re: [LTP] [PATCH] diotest: set errno with zero before test with zero > > > > > > ----- Original Message ----- > > From: "Cyril Hrubis" <chru...@suse.cz> > > To: "Zorro Lang" <zl...@redhat.com> > > Cc: ltp-list@lists.sourceforge.net > > Sent: Monday, 8 December, 2014 12:53:50 PM > > Subject: Re: [LTP] [PATCH] diotest: set errno with zero before test with > > zero > > > > Hi! > > > ret = read(fd, buf, count); > > > if (ret >= 0 || errno != errnum) { > > > tst_resm(TFAIL, "read allows %s. returns %d: %s", msg, ret, > > > strerror(errno)); > > > l_fail = TRUE; > > > > As far as I can see this code tests that read() has returned negative > > value and in this case errno must be set. > > > > I.e. > > > > if ret >= 0 -> read hasn't failed -> FAILURE > > > > The errno != errnum is not evaluated unless the first condition has > > failed (that means ret < 0) and in this case errno must be set. > > > > The condition is equivalent to !(ret < 0 && errno == errnum) > > > > Or am I missing something? > > I think he refers to output of tst_resm being possibly misleading > in case ret >= 0, that call is using strerror(errno). > > Regards, > Jan > > > > > -- > > Cyril Hrubis > > chru...@suse.cz > > > > ------------------------------------------------------------------------------ > > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > > with Interactivity, Sharing, Native Excel Exports, App Integration & more > > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > > _______________________________________________ > > Ltp-list mailing list > > Ltp-list@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/ltp-list > > > ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list