From: Cyril Hrubis <chrubis@suse.cz>
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] diotest: set errno with zero before test with zero
Date: Mon, 8 Dec 2014 13:13:04 +0100 [thread overview]
Message-ID: <20141208121304.GE11071@rei.suse.de> (raw)
In-Reply-To: <648997700.14823290.1418040193631.JavaMail.zimbra@redhat.com>
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).
Ah, now that makes sense.
Looks like a reasonable solution. Any other solution that I can think of
would add one more if statement...
--
Cyril Hrubis
chrubis@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
next prev parent reply other threads:[~2014-12-08 12:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-05 10:47 [LTP] [PATCH] diotest: set errno with zero before test with zero Zorro Lang
2014-12-08 11:53 ` Cyril Hrubis
[not found] ` <648997700.14823290.1418040193631.JavaMail.zimbra@redhat.com>
2014-12-08 12:13 ` Cyril Hrubis [this message]
2014-12-08 13:43 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141208121304.GE11071@rei.suse.de \
--to=chrubis@suse.cz \
--cc=jstancek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox